Comment redundant load banlancing and CORS headers

This commit is contained in:
hieupq 2026-03-25 23:18:50 +07:00
parent 9df4401c47
commit 6f913eb2cb

View File

@ -1,10 +1,11 @@
upstream backend { # upstream backend {
server 100.66.170.15:8080; # server 100.66.170.15:8080;
server 127.0.0.1:8080; # server 127.0.0.1:8080;
server 172.18.10.8:8080; # server 172.18.10.8:8080;
} # }
server { server {
listen 80; listen 80;
set $backend_server 172.18.10.8:8080;
root /usr/share/nginx/html; root /usr/share/nginx/html;
# Default file to serve for directory requests # Default file to serve for directory requests
@ -25,7 +26,7 @@ server {
} }
location /api/ { location /api/ {
proxy_pass http://100.66.170.15:8080; proxy_pass http://$backend_server;
# Cho phép upload file lớn (vd: 200MB) # Cho phép upload file lớn (vd: 200MB)
client_max_body_size 200M; client_max_body_size 200M;
@ -38,17 +39,17 @@ server {
proxy_connect_timeout 300s; proxy_connect_timeout 300s;
proxy_send_timeout 300s; proxy_send_timeout 300s;
# CORS headers # CORS headers - Comment vi da xu ly o backend C#
add_header 'Access-Control-Allow-Origin' '*' always; # add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always; # add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
if ($request_method = OPTIONS) { if ($request_method = OPTIONS) {
return 204; return 204;
} }
} }
location /api/Sse/events { location /api/Sse/events {
proxy_pass http://backend/api/Sse/events; proxy_pass http://$backend_server/api/Sse/events;
proxy_http_version 1.1; proxy_http_version 1.1;
# cần thiết cho SSE # cần thiết cho SSE