refactor Nginx configuration for improved backend and frontend proxy handling
This commit is contained in:
2
back
2
back
Submodule back updated: 453930251b...812e30a2f8
@ -1,38 +1,67 @@
|
||||
upstream backned {
|
||||
server unix:/app/run/socket.sock;
|
||||
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=STATIC:10m inactive=7d use_temp_path=off;
|
||||
|
||||
upstream backend
|
||||
{
|
||||
server unix:/app/run/socket0.sock;
|
||||
server unix:/app/run/socket1.sock;
|
||||
server unix:/app/run/socket2.sock;
|
||||
server unix:/app/run/socket3.sock;
|
||||
}
|
||||
|
||||
upstream frontend {
|
||||
server front:3000;
|
||||
upstream frontend
|
||||
{
|
||||
server front:3000;
|
||||
}
|
||||
|
||||
server
|
||||
{
|
||||
listen 80; server_name crm.logidex.ru;
|
||||
gzip on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 4;
|
||||
gzip_types text/css application/javascript image/svg+xml application/json text/plain text/xml;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name crm.logidex.ru;
|
||||
# Общие proxy_set_header, унаследованные всеми location
|
||||
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;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
location /api {
|
||||
proxy_pass http://backned;
|
||||
|
||||
proxy_set_header Host $http_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 /api
|
||||
{
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
|
||||
location /
|
||||
{
|
||||
proxy_pass http://frontend;
|
||||
}
|
||||
|
||||
location /_next/webpack-hmr
|
||||
{
|
||||
proxy_pass http://frontend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
|
||||
location /_next/static
|
||||
{
|
||||
proxy_cache STATIC;
|
||||
proxy_pass http://frontend;
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://frontend;
|
||||
proxy_set_header Host $http_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 /_next/webpack-hmr {
|
||||
proxy_pass http://frontend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
location /static
|
||||
{
|
||||
proxy_cache STATIC;
|
||||
proxy_ignore_headers Cache-Control;
|
||||
proxy_cache_valid 60m;
|
||||
proxy_pass http://frontend;
|
||||
}
|
||||
}
|
||||
@ -11,8 +11,6 @@ services:
|
||||
restart: unless-stopped
|
||||
front:
|
||||
image: git.logidex.ru/fakz9/crm-frontend:latest
|
||||
depends_on:
|
||||
- back
|
||||
env_file:
|
||||
- config/front/.env
|
||||
networks:
|
||||
@ -25,6 +23,7 @@ services:
|
||||
- "443:443"
|
||||
depends_on:
|
||||
- back
|
||||
- front
|
||||
volumes:
|
||||
- type: bind
|
||||
source: ./config/nginx/nginx.conf
|
||||
|
||||
2
front
2
front
Submodule front updated: cd034bcce6...1047a0b5fe
Reference in New Issue
Block a user