When nginx is configured as reverse proxy, can it rewrite the host header to the downstream server like Apache's ProxyPreserveHost?
19,150
A working example:
set $s3_bucket 'SOMEBUCKET.s3.amazonaws.com';
location / {
send_timeout 5m;
proxy_read_timeout 240;
proxy_send_timeout 240;
proxy_connect_timeout 240;
proxy_http_version 1.1;
proxy_set_header Host $s3_bucket;
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_ignore_headers "Set-Cookie";
proxy_buffering off;
proxy_intercept_errors on;
proxy_redirect off;
resolver 8.8.8.8;
proxy_pass http://$s3_bucket;
}
Related videos on Youtube
Author by
Admin
Updated on September 17, 2022Comments
-
Admin over 1 year
I can't seem to find the equivalent of Apache's ProxyPreserveHost http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#proxypreservehost option in nginx. This is required to reverse proxy to virtual hosts.
What it does is replace the host name the browser provides with the host name of the downstream server.
Does it exist?
-
cod3fr3ak almost 11 yearsThis is using nginx.