Fix internal nginx config
This commit is contained in:
1 parent
b5630d2af7
commit
35bff424f1
2 files changed
+13
-11
No files matched your search
+7
-6
@@ -23,17 +23,18 @@ server {
|
|||||||
|
|
||||||
# Proxy the API to the Go backend running alongside nginx.
|
# Proxy the API to the Go backend running alongside nginx.
|
||||||
#
|
#
|
||||||
# X-Forwarded-For is set to $remote_addr (the peer nginx actually saw), NOT
|
# This nginx normally sits behind a parent (SSL-terminating) proxy, so the
|
||||||
# $proxy_add_x_forwarded_for. The latter appends to any client-supplied
|
# parent has already resolved the real client IP into X-Forwarded-For.
|
||||||
# header, which would let a client spoof its own IP since the backend trusts
|
# Appending with $proxy_add_x_forwarded_for preserves that first entry, which
|
||||||
# the leftmost value. If you deploy behind another trusted proxy, switch to
|
# is what the backend reads (auth.ExtractIP uses the leftmost value).
|
||||||
# $proxy_add_x_forwarded_for and make the backend read the correct hop.
|
# Do NOT use $remote_addr here: it would replace the parent's header with the
|
||||||
|
# parent's own address (e.g. the Docker bridge gateway 172.20.0.1).
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://${BACKEND_HOST}:${BACKEND_PORT};
|
proxy_pass http://${BACKEND_HOST}:${BACKEND_PORT};
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $remote_addr;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,16 +27,17 @@ server {
|
|||||||
# Reverse proxy the API to the Go service. Keeping the same origin means
|
# Reverse proxy the API to the Go service. Keeping the same origin means
|
||||||
# the session cookie (SameSite=Lax) and CSRF cookie work without CORS.
|
# the session cookie (SameSite=Lax) and CSRF cookie work without CORS.
|
||||||
#
|
#
|
||||||
# X-Forwarded-For uses $remote_addr (the immediate peer) so a client cannot
|
# $proxy_add_x_forwarded_for appends the immediate peer to X-Forwarded-For,
|
||||||
# spoof its recorded session IP; the backend trusts the leftmost value. If
|
# so when a parent proxy resolves the real client IP first, the backend
|
||||||
# this nginx sits behind another trusted proxy, use $proxy_add_x_forwarded_for
|
# (which reads the leftmost value) still sees it. Only switch to $remote_addr
|
||||||
# and make the backend read the appropriate hop instead.
|
# if this nginx is the outermost/edge proxy and you want to reject
|
||||||
|
# client-supplied X-Forwarded-For.
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://127.0.0.1:8080;
|
proxy_pass http://127.0.0.1:8080;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $remote_addr;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user