From 3db0fcf17bd20a124e76dd4976c1f3647515c4fa Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Mon, 5 Dec 2022 01:38:51 +0100 Subject: [PATCH] added sample nginx demo config --- nginx-vhost.dev-example.conf | 110 +++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 nginx-vhost.dev-example.conf diff --git a/nginx-vhost.dev-example.conf b/nginx-vhost.dev-example.conf new file mode 100644 index 0000000..524559f --- /dev/null +++ b/nginx-vhost.dev-example.conf @@ -0,0 +1,110 @@ +upstream egommerce-api-gw { + server 127.0.0.1:48443; +} + +upstream egommerce-api-gw-dashboard { + server 127.0.0.1:48444; +} + +upstream egommerce-api-registry-ui { + server 127.0.0.1:48445; +} + +upstream egommerce-api-eventbus-mngmt { + server 127.0.0.1:48446; +} + +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; + + # Traefik redirects + location /dashboard { + if ($http_referer ~ (/admin/gateway)) { + proxy_pass http://egommerce-api-gw-dashboard; + } + } + location /api { + if ($http_referer ~ (/admin/gateway)) { + proxy_pass http://egommerce-api-gw-dashboard; + } + } + + location /admin/gateway/ { + proxy_pass http://egommerce-api-gw-dashboard/dashboard/; + 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; + } + + + # Consul redirects + location /ui { + if ($http_referer ~ (/admin/registry)) { + proxy_pass http://egommerce-api-registry-ui; + } + } + + location /v1 { + if ($http_referer ~ (/admin/registry)) { + proxy_pass http://egommerce-api-registry-ui; + } + } + + location /admin/registry { + proxy_pass http://egommerce-api-registry-ui; + 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; + } + + + # RabbitMQ Mngmt redirects + location /admin/eventbus { + return 302 /admin/eventbus/; + } + location ~* /admin/eventbus/api/(.*?)/(.*) { + proxy_pass http://egommerce-api-eventbus-mngmt/api/$1/%2F/$2?$query_string; + proxy_buffering off; + 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; + } + location ~* /admin/eventbus/(.*) { + rewrite ^/admin/eventbus/(.*)$ /$1 break; + proxy_pass http://egommerce-api-eventbus-mngmt; + proxy_buffering off; + 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; + } + + # Pass all other requests to the API Gateway directly + 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; +} +