nginx example config update

This commit is contained in:
Piotr Biernat 2022-12-05 03:13:27 +01:00
parent 17c64b31f5
commit 5bd2f273a9

View File

@ -16,24 +16,24 @@ upstream egommerce-api-eventbus-mngmt {
server { server {
listen 443 ssl; listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/egommerce.pbiernat.dev/fullchain.pem; ssl_certificate /etc/letsencrypt/live/admin.egommerce.pbiernat.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/egommerce.pbiernat.dev/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/admin.egommerce.pbiernat.dev/privkey.pem;
server_name egommerce.pbiernat.dev; server_name admin.egommerce.pbiernat.dev;
# Traefik redirects # Traefik redirects
location /dashboard { location /dashboard {
if ($http_referer ~ (/admin/gateway)) { if ($http_referer ~ (/gateway)) {
proxy_pass http://egommerce-api-gw-dashboard; proxy_pass http://egommerce-api-gw-dashboard;
} }
} }
location /api { location /api {
if ($http_referer ~ (/admin/gateway)) { if ($http_referer ~ (/gateway)) {
proxy_pass http://egommerce-api-gw-dashboard; proxy_pass http://egommerce-api-gw-dashboard;
} }
} }
location /admin/gateway/ { location /gateway/ {
proxy_pass http://egommerce-api-gw-dashboard/dashboard/; proxy_pass http://egommerce-api-gw-dashboard/dashboard/;
proxy_pass_header Server; proxy_pass_header Server;
proxy_set_header Host $host; proxy_set_header Host $host;
@ -43,21 +43,20 @@ server {
client_max_body_size 0; client_max_body_size 0;
} }
# Consul redirects # Consul redirects
location /ui { location /ui {
if ($http_referer ~ (/admin/registry)) { if ($http_referer ~ (/registry)) {
proxy_pass http://egommerce-api-registry-ui; proxy_pass http://egommerce-api-registry-ui;
} }
} }
location /v1 { location /v1 {
if ($http_referer ~ (/admin/registry)) { if ($http_referer ~ (/registry)) {
proxy_pass http://egommerce-api-registry-ui; proxy_pass http://egommerce-api-registry-ui;
} }
} }
location /admin/registry { location /registry {
proxy_pass http://egommerce-api-registry-ui; proxy_pass http://egommerce-api-registry-ui;
proxy_pass_header Server; proxy_pass_header Server;
proxy_set_header Host $host; proxy_set_header Host $host;
@ -69,10 +68,10 @@ server {
# RabbitMQ Mngmt redirects # RabbitMQ Mngmt redirects
location /admin/eventbus { location /eventbus {
return 302 /admin/eventbus/; return 302 /eventbus/;
} }
location ~* /admin/eventbus/api/(.*?)/(.*) { location ~* /eventbus/api/(.*?)/(.*) {
proxy_pass http://egommerce-api-eventbus-mngmt/api/$1/%2F/$2?$query_string; proxy_pass http://egommerce-api-eventbus-mngmt/api/$1/%2F/$2?$query_string;
proxy_buffering off; proxy_buffering off;
proxy_pass_header Server; proxy_pass_header Server;
@ -81,8 +80,8 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
location ~* /admin/eventbus/(.*) { location ~* /eventbus/(.*) {
rewrite ^/admin/eventbus/(.*)$ /$1 break; rewrite ^/eventbus/(.*)$ /$1 break;
proxy_pass http://egommerce-api-eventbus-mngmt; proxy_pass http://egommerce-api-eventbus-mngmt;
proxy_buffering off; proxy_buffering off;
proxy_pass_header Server; proxy_pass_header Server;
@ -92,19 +91,30 @@ server {
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
} }
# Pass all other requests to the API Gateway directly error_log /var/log/nginx/admin-egommerce.pbiernat.dev-error.log;
location / { access_log /var/log/nginx/admin-egommerce.pbiernat.dev-access.log combined;
proxy_pass https://egommerce-api-gw;
proxy_http_version 1.1;
proxy_pass_header Server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0;
}
error_log /var/log/nginx/egommerce.pbiernat.dev-error.log;
access_log /var/log/nginx/egommerce.pbiernat.dev-access.log combined;
} }
#server {
# listen 443 ssl;
# ssl_certificate /etc/letsencrypt/live/egommerce.pbiernat.dev/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/egommerce.pbiernat.dev/privkey.pem;
#
# server_name egommerce.pbiernat.dev;
#
# # Pass all requests to the API Gateway
# location / {
# proxy_pass https://egommerce-api-gw;
# proxy_http_version 1.1;
# proxy_pass_header Server;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# client_max_body_size 0;
# }
#
# error_log /var/log/nginx/egommerce.pbiernat.dev-error.log;
# access_log /var/log/nginx/egommerce.pbiernat.dev-access.log combined;
#}