config: add include custom upstream and location

This commit is contained in:
vchikalkin 2023-10-18 13:17:34 +03:00
parent 43126e3425
commit a683bc30cc
4 changed files with 73 additions and 79 deletions

View File

View File

View File

@ -1,93 +1,86 @@
worker_processes auto;
events {
worker_connections 1024;
upstream web {
server web:3000;
}
http {
upstream web {
server web:3000;
}
upstream api {
server api:3001;
}
upstream app {
server application:80;
}
server {
listen 80;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_comp_level 1;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/json application/xml application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
gzip_vary on;
gzip_disable "msie6";
error_page 401 /login;
location = /auth {
internal;
proxy_pass http://api;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Original-Remote-Addr $remote_addr;
proxy_set_header X-Original-Host $host;
proxy_intercept_errors on;
}
location ~ ^/(signin|logout|get-user) {
proxy_pass http://api;
proxy_redirect off;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Original-Remote-Addr $remote_addr;
proxy_set_header X-Original-Host $host;
}
location ~ ^/login {
proxy_pass http://web;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
auth_request /auth;
auth_request_set $auth_cookie $upstream_http_set_cookie;
add_header Set-Cookie $auth_cookie;
}
location = /health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 'UP';
}
}
upstream api {
server api:3001;
}
upstream app {
server application:80;
}
include /etc/nginx/include/upstream.conf;
server {
listen 80;
include /etc/nginx/mime.types;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_comp_level 1;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/json application/xml application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
gzip_vary on;
gzip_disable "msie6";
error_page 401 /login;
location = /auth {
internal;
proxy_pass http://api;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Original-Remote-Addr $remote_addr;
proxy_set_header X-Original-Host $host;
proxy_intercept_errors on;
}
location ~ ^/(signin|logout|get-user) {
proxy_pass http://api;
proxy_redirect off;
proxy_set_header X-Original-URI $request_uri;
proxy_set_header X-Original-Remote-Addr $remote_addr;
proxy_set_header X-Original-Host $host;
}
location ~ ^/login {
proxy_pass http://web;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
auth_request /auth;
auth_request_set $auth_cookie $upstream_http_set_cookie;
add_header Set-Cookie $auth_cookie;
}
location = /health {
access_log off;
add_header 'Content-Type' 'application/json';
return 200 'UP';
}
include /etc/nginx/include/location.conf;
}

View File

@ -42,6 +42,7 @@ services:
image: nginx:alpine
volumes:
- ./config/nginx.conf:/etc/nginx/templates/default.conf.template
- ./config/include:/etc/nginx/include
restart: always
depends_on:
- web