proxy_redirect not working with "refresh"

Francis Daly francis at daoine.org
Thu Apr 30 08:11:19 UTC 2015


On Thu, Apr 30, 2015 at 02:43:14AM -0400, John wrote:

Hi there,

> http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect says:
> 
> "(proxy_redirect) Sets the text that should be changed in the “Location” and “Refresh” header fields of a proxied server response."
> 
> All examples I found online only mentioned how it works with "Location", and that also works perfectly with me.
> 
> But it just doesn't work with "Refresh" for me.  My backend site http://192.168.1.9/test.html is:
> 
> <html><head> 
> <meta http-equiv="refresh" content="0;url=http://192.168.1.9/" />
> </head></html>

That's not a "Refresh" header field.

That is something in the http response body.

In general, nginx doesn't mess with the response body.

(You can configure it to, but I tend to dislike doing that.)

> Did I miss anything?  Actually I don't understand that line about "proxy_set_header Host $host", I just copied from web.

Why does your back-end include the string "http://192.168.1.9/" in its
response body?

Can you make it instead include a string based on the Host: header it
receives? If so, that is what the "proxy_set_header Host $host" is for.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list