Skip to content

Commit

Permalink
add nginx (#54)
Browse files Browse the repository at this point in the history
* add nginx

* config yml in product
  • Loading branch information
khanhduzz authored Oct 9, 2024
1 parent 9ac5312 commit 45a39b6
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 25 deletions.
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
version: "3.9"

services:
nginx:
image: nginx:1.25.3
restart: unless-stopped
volumes:
- ./nginx/templates:/etc/nginx/templates
- ./nginx/configuration/custom_proxy_settings.conf:/etc/nginx/conf.d/custom_proxy_settings.conf
ports:
- "80:80"
networks:
- matcha-network

keycloak:
image: quay.io/keycloak/keycloak:21.0.2
command: [ 'start-dev --import-realm' ]
Expand Down
1 change: 1 addition & 0 deletions nginx/configuration/custom_proxy_settings.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client_max_body_size 30m;
37 changes: 37 additions & 0 deletions nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
server {
server_name 127.0.0.11;

# Docker DNS
resolver 127.0.0.11;

location /swagger-ui/ {
proxy_pass http://swagger-ui:8090;
}
location /product/ {
proxy_pass http://product;
}
}

server {
server_name sell;
location / {
proxy_pass http://sell;
}
}

server {
server_name identity;
large_client_header_buffers 8 32k;
location / {
proxy_pass http://identity;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Workaround to void CORS error from Reactjs
if ($uri ~ "^(.*)/(protocol/openid-connect/auth|login/oauth2/code)(.*)") {
add_header Access-Control-Allow-Origin *;
}
}
}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<jacoco.version>0.8.12</jacoco.version>
<jacoco.minimumInstructionCoverage>0.00</jacoco.minimumInstructionCoverage>
<spring-cloud.version>2023.0.3</spring-cloud.version>
<dotenv-version>4.0.0</dotenv-version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -93,6 +94,11 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>me.paulschwarz</groupId>
<artifactId>spring-dotenv</artifactId>
<version>${dotenv-version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
3 changes: 3 additions & 0 deletions product/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPRING_DATASOURCE_URL=
SPRING_DATA_USERNAME=
SPRING_DATA_PASSWORD=
1 change: 1 addition & 0 deletions product/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ build/

### VS Code ###
.vscode/
.env
14 changes: 0 additions & 14 deletions product/src/main/resources/application.properties

This file was deleted.

20 changes: 20 additions & 0 deletions product/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
spring:
application:
name: product
datasource:
url: ${SPRING_DATASOURCE_URL}
username: ${SPRING_DATA_USERNAME}
password: ${SPRING_DATA_PASSWORD}
driver-class-name: org.postgresql.Driver

jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
hibernate:
ddl-auto: update
show-sql: true

server:
port: 8081
7 changes: 3 additions & 4 deletions product/src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ server.servlet.context-path=/product

spring.profiles.active=test

spring.data.mongodb.uri=jdbc:h2:mem:testdb;NON_KEYWORDS=VALUE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.hibernate.ddl-auto=update
spring.liquibase.enabled=false
7 changes: 0 additions & 7 deletions sell-bff/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,3 @@ spring:
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=
- id: api
uri: http://api.matcha.local
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=

0 comments on commit 45a39b6

Please sign in to comment.