358 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			358 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| # ------------------------------------------------------------
 | |
| # lcbp3.np-dms.work
 | |
| # ------------------------------------------------------------
 | |
| 
 | |
| 
 | |
| 
 | |
| map $scheme $hsts_header {
 | |
|     https   "max-age=63072000; preload";
 | |
| }
 | |
| 
 | |
| server {
 | |
|   set $forward_scheme http;
 | |
|   set $server         "dms_frontend";
 | |
|   set $port           3000;
 | |
| 
 | |
|   listen 80;
 | |
| listen [::]:80;
 | |
| 
 | |
| 
 | |
|   server_name lcbp3.np-dms.work;
 | |
| 
 | |
|   http2 on;
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| proxy_set_header Upgrade $http_upgrade;
 | |
| proxy_set_header Connection $http_connection;
 | |
| proxy_http_version 1.1;
 | |
| 
 | |
| 
 | |
|   access_log /data/logs/proxy-host-3_access.log proxy;
 | |
|   error_log /data/logs/proxy-host-3_error.log warn;
 | |
| 
 | |
| # ===== ขนาดไฟล์/timeout ระดับ Host =====
 | |
| client_max_body_size 200m;
 | |
| client_body_timeout  60s;
 | |
| send_timeout         60s;
 | |
| 
 | |
| # ===== WebSocket/SSE header ระดับ Host =====
 | |
| proxy_set_header Upgrade    $http_upgrade;
 | |
| proxy_set_header Connection $connection_upgrade;
 | |
| 
 | |
| # ===== Security headers ระดับ Host =====
 | |
| add_header X-Content-Type-Options nosniff always;
 | |
| add_header X-Frame-Options SAMEORIGIN always;
 | |
| add_header Referrer-Policy "no-referrer-when-downgrade" always;
 | |
| # เปิด HSTS เมื่อมั่นใจว่าทุก subdomain ใช้ HTTPS เท่านั้น
 | |
| # add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
 | |
| 
 | |
|   location /health {
 | |
|     proxy_http_version 1.1;
 | |
| proxy_set_header Host  $host;
 | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 | |
| proxy_set_header X-Forwarded-Proto https;
 | |
| proxy_read_timeout 15s;
 | |
| proxy_send_timeout 15s;
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_frontend:3000;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
|   location /_next/static/ {
 | |
|     proxy_http_version 1.1;
 | |
| proxy_set_header Host $host;
 | |
| add_header Cache-Control "public, max-age=31536000, immutable";
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_frontend:3000;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
|   location /api/ {
 | |
|     proxy_http_version 1.1;
 | |
| 
 | |
| 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 https;
 | |
| 
 | |
| # WebSocket/SSE เผื่อใช้
 | |
| proxy_set_header Upgrade $http_upgrade;
 | |
| proxy_set_header Connection "upgrade";
 | |
| 
 | |
| proxy_read_timeout 300s;
 | |
| proxy_send_timeout 300s;
 | |
| proxy_redirect off;
 | |
| 
 | |
| # ---- CORS allowlist ----
 | |
| set $cors_allow_origin "";
 | |
| if ($http_origin ~* "^https?://(localhost(:\\d+)?|127\\.0\\.0\\.1(:\\d+)?|np-dms\\.work|www\\.np-dms\\.work|lcbp3\\.np-dms\\.work)$") {
 | |
|   set $cors_allow_origin $http_origin;
 | |
| }
 | |
| add_header Access-Control-Allow-Origin $cors_allow_origin always;
 | |
| add_header Vary "Origin" always;
 | |
| add_header Access-Control-Allow-Credentials "true" always;
 | |
| add_header Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS" always;
 | |
| add_header Access-Control-Allow-Headers "Authorization, Content-Type, Accept, Origin, Referer, User-Agent, X-Requested-With, Cache-Control, Pragma" always;
 | |
| 
 | |
| if ($request_method = OPTIONS) {
 | |
|   add_header Content-Length 0;
 | |
|   add_header Content-Type text/plain;
 | |
|   return 204;
 | |
| }
 | |
| 
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_backend:3001;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
|   location /pma/ {
 | |
|     proxy_http_version 1.1;
 | |
| proxy_set_header Host $host;
 | |
| proxy_set_header X-Forwarded-Host $host;
 | |
| proxy_set_header X-Forwarded-Proto https;
 | |
| proxy_set_header X-Forwarded-Prefix /pma;
 | |
| proxy_read_timeout 300s;
 | |
| proxy_send_timeout 300s;
 | |
| proxy_redirect off;
 | |
| 
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_phpmyadmin:80;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
|   location /n8n {
 | |
|     rewrite ^/n8n$ /n8n/ permanent;
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_frontend:80;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
|   location /n8n/ {
 | |
|     proxy_http_version 1.1;
 | |
| proxy_set_header Host $host;
 | |
| proxy_set_header X-Forwarded-Host $host;
 | |
| proxy_set_header X-Forwarded-Proto https;
 | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 | |
| proxy_set_header X-Forwarded-Prefix /n8n;
 | |
| 
 | |
| proxy_set_header Upgrade $http_upgrade;
 | |
| proxy_set_header Connection "upgrade";
 | |
| 
 | |
| proxy_read_timeout 86400s;
 | |
| proxy_send_timeout 86400s;
 | |
| proxy_redirect off;
 | |
| 
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_n8n:5678;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
|   location /pgadmin {
 | |
|     rewrite ^/pgadmin$ /pgadmin/ permanent;
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_frontend:3000;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
|   location /pgadmin/ {
 | |
|     proxy_http_version 1.1;
 | |
| proxy_set_header Host $host;
 | |
| proxy_set_header X-Script-Name /pgadmin;
 | |
| proxy_set_header X-Forwarded-Prefix /pgadmin;
 | |
| proxy_set_header X-Forwarded-Host $host;
 | |
| proxy_set_header X-Forwarded-Proto https;
 | |
| proxy_read_timeout 300s;
 | |
| proxy_send_timeout 300s;
 | |
| proxy_redirect off;
 | |
| 
 | |
|     proxy_set_header Host $host;
 | |
|     proxy_set_header X-Forwarded-Scheme $scheme;
 | |
|     proxy_set_header X-Forwarded-Proto  $scheme;
 | |
|     proxy_set_header X-Forwarded-For    $remote_addr;
 | |
|     proxy_set_header X-Real-IP		$remote_addr;
 | |
| 
 | |
|     proxy_pass       http://dms_pgadmin:80;
 | |
| 
 | |
|     
 | |
| 
 | |
|     
 | |
|     
 | |
|     
 | |
|     
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
|   }
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|   location / {
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
|     
 | |
|     proxy_set_header Upgrade $http_upgrade;
 | |
|     proxy_set_header Connection $http_connection;
 | |
|     proxy_http_version 1.1;
 | |
|     
 | |
| 
 | |
|     # Proxy!
 | |
|     include conf.d/include/proxy.conf;
 | |
|   }
 | |
| 
 | |
| 
 | |
|   # Custom
 | |
|   include /data/nginx/custom/server_proxy[.]conf;
 | |
| }
 |