Skip to content

Commit

Permalink
made nginx proxy protocol correctly when behind a second reverse proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
jabelone committed Aug 28, 2023
1 parent 99e2873 commit 736c15a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ http {
server localhost:8001 fail_timeout=10s;
}

# if another reverse proxy is used the forwarded protocol may be wrong without this check
map $http_x_forwarded_proto $proxied_scheme {
default $http_x_forwarded_proto;
"" $scheme;
}

server {
listen 8000 deferred default_server;
client_max_body_size 10M;
Expand Down Expand Up @@ -63,7 +69,7 @@ http {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $http_x_real_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto $proxied_scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_redirect off;
Expand All @@ -79,7 +85,7 @@ http {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $http_x_real_ip;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto $proxied_scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
Expand Down

0 comments on commit 736c15a

Please sign in to comment.