@@ -1075,7 +1075,7 @@ following `Nginx` config:
1075
1075
1076
1076
``` console
1077
1077
location /get {
1078
- proxy_pass http://httpbin.org/get
1078
+ proxy_pass http://httpbin.org/get;
1079
1079
}
1080
1080
```
1081
1081
@@ -1094,6 +1094,36 @@ Verify using `curl -v localhost:8899/get`:
1094
1094
}
1095
1095
```
1096
1096
1097
+ #### Rewrite Host Header
1098
+
1099
+ With above example, you may sometimes see:
1100
+
1101
+ ``` console
1102
+ >
1103
+ * Empty reply from server
1104
+ * Closing connection
1105
+ curl: (52) Empty reply from server
1106
+ ```
1107
+
1108
+ This is happenening because our default reverse proxy plugin ` ReverseProxyPlugin ` is configured
1109
+ with a ` http ` and a ` https ` upstream server. And, by default ` ReverseProxyPlugin ` preserves the
1110
+ original host header. While this works with ` https ` upstreams, this doesn't work reliably with
1111
+ ` http ` upstreams. To work around this problem use the ` --rewrite-host-header ` flags.
1112
+
1113
+ Example:
1114
+
1115
+
1116
+ ``` console
1117
+ ❯ proxy --enable-reverse-proxy \
1118
+ --plugins proxy.plugin.ReverseProxyPlugin \
1119
+ --rewrite-host-header
1120
+ ```
1121
+
1122
+ This will ensure that ` Host ` header field is set as ` httpbin.org ` and works with both ` http ` and
1123
+ ` https ` upstreams.
1124
+
1125
+ > NOTE: Whether to use ` --rewrite-host-header ` or not depends upon your use-case.
1126
+
1097
1127
## Plugin Ordering
1098
1128
1099
1129
When using multiple plugins, depending upon plugin functionality,
@@ -2613,7 +2643,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
2613
2643
[--proxy-pool PROXY_POOL] [--enable-web-server]
2614
2644
[--enable-static-server] [--static-server-dir STATIC_SERVER_DIR]
2615
2645
[--min-compression-length MIN_COMPRESSION_LENGTH]
2616
- [--enable-reverse-proxy] [--enable-metrics]
2646
+ [--enable-reverse-proxy] [--rewrite-host-header] [-- enable-metrics]
2617
2647
[--metrics-path METRICS_PATH] [--pac-file PAC_FILE]
2618
2648
[--pac-file-url-path PAC_FILE_URL_PATH]
2619
2649
[--cloudflare-dns-mode CLOUDFLARE_DNS_MODE]
@@ -2622,7 +2652,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
2622
2652
[--filtered-client-ips FILTERED_CLIENT_IPS]
2623
2653
[--filtered-url-regex-config FILTERED_URL_REGEX_CONFIG]
2624
2654
2625
- proxy.py v2.4.6.dev25+g2754b928.d20240812
2655
+ proxy.py v2.4.8.dev8+gc703edac.d20241013
2626
2656
2627
2657
options:
2628
2658
-h, --help show this help message and exit
@@ -2791,6 +2821,9 @@ options:
2791
2821
response that will be compressed (gzipped).
2792
2822
--enable-reverse-proxy
2793
2823
Default: False. Whether to enable reverse proxy core.
2824
+ --rewrite-host-header
2825
+ Default: False. If used, reverse proxy server will
2826
+ rewrite Host header field before sending to upstream.
2794
2827
--enable-metrics Default: False. Enables metrics.
2795
2828
--metrics-path METRICS_PATH
2796
2829
Default: /metrics. Web server path to serve proxy.py
0 commit comments