Skip to content

Commit

Permalink
config ngxin run good with keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduzz committed Oct 10, 2024
1 parent e2f231b commit e9ef4f5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ services:
- ./identity/themes/matcha/theme:/opt/keycloak/themes
networks:
- matcha-network
ports:
- "8080:80"

postgres:
image: debezium/postgres:15-alpine
Expand Down
25 changes: 7 additions & 18 deletions nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
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 sell;
# location / {
# proxy_pass http://localhost:8181;
# }
#}

server {
server_name identity;
large_client_header_buffers 8 32k;
location / {
proxy_pass http://identity;
proxy_pass http://keycloak:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
<dependency>
<groupId>me.paulschwarz</groupId>
<artifactId>spring-dotenv</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
13 changes: 9 additions & 4 deletions product/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ spring:
driver-class-name: org.postgresql.Driver

jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
hibernate:
ddl-auto: update
show-sql: true
properties:
hibernate:
format_sql: false
database: postgresql
database-platform: org.hibernate.dialect.PostgreSQLDialect
open-in-view: false

dotenv:
file: ../.env

server:
port: 8081
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http)
return http
.authorizeExchange(auth -> auth
.pathMatchers("/health").permitAll()
.anyExchange().hasAnyRole("ADMIN"))
// .anyExchange().hasAnyRole("ADMIN"))
.anyExchange().permitAll())
.oauth2Login(Customizer.withDefaults())
.httpBasic(ServerHttpSecurity.HttpBasicSpec::disable)
.formLogin(ServerHttpSecurity.FormLoginSpec::disable)
Expand Down
9 changes: 8 additions & 1 deletion sell-bff/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ spring:
gateway:
routes:
# Changes for your local development should not be committed
- id: api_product_local
- id: product
uri: http://localhost:8081
predicates:
- Path=/api/product/**
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=
- id: localhost
uri: http://localhost:80
predicates:
- Path=/api/**
filters:
- RewritePath=/api/(?<segment>.*), /$\{segment}
- TokenRelay=

0 comments on commit e9ef4f5

Please sign in to comment.