Skip to content

Commit bc694d3

Browse files
authored
Merge pull request #4 from Intellection/forward_headers_to_upstream
Forward X-Forwarded-* headers to upstream correctly
2 parents 181ff1e + 2af53f4 commit bc694d3

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.19.5-2
4+
5+
* Forward `X-Forwarded-*` headers to upstream correctly.
6+
37
## 1.19.5-1
48

59
* Change health check port from `18080` to `18081`.

config/http.conf

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,36 @@ http {
99
client_max_body_size 400m;
1010
client_body_timeout 300s;
1111

12+
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
13+
# scheme used to connect to this server
14+
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
15+
default $http_x_forwarded_proto;
16+
'' $scheme;
17+
}
18+
19+
# If we receive X-Forwarded-Proto, use it to determine the value of
20+
# X-Forwarded-Ssl
21+
map $http_x_forwarded_proto $proxy_x_forwarded_ssl {
22+
default off;
23+
https on;
24+
}
25+
26+
# If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
27+
# server port the client connected to
28+
map $http_x_forwarded_port $proxy_x_forwarded_port {
29+
default $http_x_forwarded_port;
30+
'' $server_port;
31+
}
32+
1233
proxy_http_version 1.1;
1334
proxy_set_header Connection "";
1435
proxy_set_header Host $host;
1536

1637
proxy_set_header X-Real-IP $remote_addr;
1738
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
18-
proxy_set_header X-Forwarded-Proto $scheme;
19-
proxy_set_header X-Forwarded-Ssl on;
20-
proxy_set_header X-Forwarded-Port $server_port;
39+
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
40+
proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
41+
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
2142
proxy_set_header X-Forwarded-Host $host;
2243

2344
proxy_read_timeout 600s;

0 commit comments

Comments
 (0)