diff --git a/nginx-proxy/default.conf b/nginx-proxy/default.conf index 28e171d..6b7b15e 100644 --- a/nginx-proxy/default.conf +++ b/nginx-proxy/default.conf @@ -1,8 +1,41 @@ -# HTTP → HTTPS 重定向 +# WebSocket connection upgrade +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +# HTTP - 反代到 115.227.17.84(生产前端) server { listen 80; server_name redpowerfuture.com *.redpowerfuture.com; - return 301 https://$host$request_uri; + client_max_body_size 500M; + + location ^~ / + { + proxy_pass http://115.227.17.84; + 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 REMOTE-HOST $remote_addr; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_http_version 1.1; + # proxy_hide_header Upgrade; + + add_header X-Cache $upstream_cache_status; + #Set Nginx Cache + + set $static_filefFEkdMm2 0; + if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" ) + { + set $static_filefFEkdMm2 1; + expires 1m; + } + if ( $static_filefFEkdMm2 = 0 ) + { + add_header Cache-Control no-cache; + } + } } # HTTPS - 转发到 116.204.74.41 @@ -35,15 +68,30 @@ server { listen 80 default_server; server_name _; client_max_body_size 500M; - location / { - proxy_pass http://116.204.74.41; - proxy_http_version 1.1; + location ^~ / + { + proxy_pass http://115.227.17.84; 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; - proxy_connect_timeout 75s; - proxy_send_timeout 86400s; - proxy_read_timeout 86400s; + proxy_set_header REMOTE-HOST $remote_addr; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_http_version 1.1; + # proxy_hide_header Upgrade; + + add_header X-Cache $upstream_cache_status; + #Set Nginx Cache + + set $static_filefFEkdMm2 0; + if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" ) + { + set $static_filefFEkdMm2 1; + expires 1m; + } + if ( $static_filefFEkdMm2 = 0 ) + { + add_header Cache-Control no-cache; + } } }