Skip to content

Commit 2fa9f7a

Browse files
Merge pull request #33 from myvas:improve-nginx-conf
Add forward ip and scheme
2 parents ac255bb + b43607d commit 2fa9f7a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

conf/nginx/demo.auth.myvas.com.conf

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ server {
66
error_log /var/log/nginx/demo.auth.myvas.error.log;
77

88
# set client body size to 2M
9-
#client_max_body_size 8M;
9+
#client_max_body_size 8M;
1010

1111
error_page 502 /502.html;
1212
location = /502.html {
@@ -16,10 +16,29 @@ server {
1616

1717
location / {
1818
proxy_pass http://127.0.0.1:6605;
19+
20+
# Use HTTP/1.1 for backend communication.
1921
proxy_http_version 1.1;
22+
23+
# Forward the `Upgrade` header for WebSocket support.
2024
proxy_set_header Upgrade $http_upgrade;
25+
26+
# Enable persistent connections between Nginx and the backend.
2127
proxy_set_header Connection keep-alive;
28+
29+
# Forward the original `Host` header to the backend.
2230
proxy_set_header Host $host;
23-
proxy_cache_bypass $http_upgrade;
31+
32+
# Forward the client's real IP address to the backend.
33+
proxy_set_header X-Real-IP $remote_addr;
34+
35+
# Track the client's IP through proxies.
36+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
37+
38+
# Forward the original protocol (HTTP or HTTPS) to the backend.
39+
proxy_set_header X-Forwarded-proto $scheme;
40+
41+
# Bypass the cache for WebSocket requests.
42+
proxy_cache_bypass $http_upgrade;
2443
}
2544
}

0 commit comments

Comments
 (0)