@@ -28,6 +28,13 @@ http {
28
28
'' $host;
29
29
}
30
30
31
+ # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
32
+ # server port the client connected to
33
+ map $http_x_forwarded_port $proxy_x_forwarded_port {
34
+ default $http_x_forwarded_port;
35
+ '' $server_port;
36
+ }
37
+
31
38
# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
32
39
# scheme used to connect to this server
33
40
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
@@ -42,11 +49,32 @@ http {
42
49
https on;
43
50
}
44
51
45
- # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the
46
- # server port the client connected to
47
- map $http_x_forwarded_port $proxy_x_forwarded_port {
48
- default $http_x_forwarded_port;
49
- '' $server_port;
52
+ # If we receive X-Original-Forwarded-Host, use it; otherwise, use
53
+ # the value of X-Forwarded-Host
54
+ map $http_x_original_forwarded_host $proxy_x_forwarded_host_final {
55
+ default $http_x_original_forwarded_host;
56
+ '' $proxy_x_forwarded_host;
57
+ }
58
+
59
+ # If we receive X-Original-Forwarded-Port, use it; otherwise, use
60
+ # the value of X-Forwarded-Port
61
+ map $http_x_original_forwarded_port $proxy_x_forwarded_port_final {
62
+ default $http_x_original_forwarded_port;
63
+ '' $proxy_x_forwarded_port;
64
+ }
65
+
66
+ # If we receive X-Original-Forwarded-Proto, use it; otherwise, use
67
+ # the value of X-Forwarded-Proto
68
+ map $http_x_original_forwarded_proto $proxy_x_forwarded_proto_final {
69
+ default $http_x_original_forwarded_proto;
70
+ '' $proxy_x_forwarded_proto;
71
+ }
72
+
73
+ # If we receive X-Original-Forwarded-Ssl, use it; otherwise, use
74
+ # the value of X-Forwarded-Ssl
75
+ map $http_x_original_forwarded_ssl $proxy_x_forwarded_ssl_final {
76
+ default $http_x_original_forwarded_ssl;
77
+ '' $proxy_x_forwarded_ssl;
50
78
}
51
79
52
80
# If we receive X-Request-ID, pass it through; otherwise, pass along the
@@ -71,12 +99,12 @@ http {
71
99
proxy_set_header Proxy "";
72
100
73
101
proxy_set_header X-Real-IP $remote_addr;
74
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
75
- proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
76
- proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl;
77
- proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
78
102
proxy_set_header X-Request-ID $proxy_x_request_id;
79
- proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host;
103
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
104
+ proxy_set_header X-Forwarded-Host $proxy_x_forwarded_host_final;
105
+ proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port_final;
106
+ proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto_final;
107
+ proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl_final;
80
108
proxy_set_header X-Request-Start "t=${msec}";
81
109
82
110
# Latency headers
0 commit comments