"port_in_redirect off" not working.

Maxim Dounin mdounin at mdounin.ru
Sat Sep 10 12:08:26 UTC 2011


On Sat, Sep 10, 2011 at 07:40:31AM -0400, carrierdetect wrote:

> Hello,
> I'm running nginx/1.0.5 behing Varnish and serving up static html.
> Whenever I visit a URL which is a directory but without a trailing
> slash, e.g. /blah, it redirects to the non-80 port which nginx is
> running on, e.g. server:5000/blah/. The config is as follows:
> http {
>     include       mime.types;
>     default_type  application/octet-stream;
>     sendfile        on;
>     server {
>         listen       5000;
>         server_name  server.com;
>         root /path/html;
>         location / {
>             index  index.html index.htm;
>             port_in_redirect off;
>        }
>     }
> }

Works ok here.

> I've tried moving "port_in_redirect off" to http and server contexts,
> and setting "server_name_in_redirect off", to no avail. The Varnish
> configuration is as simple as can be and just looks for the request
> hostname and forwards to the nginx backend.

Try connecting nginx directly or looking though tcpdump to see 
what actually nginx returns.

I suspect it's actually caching issue, either Varnish cached the 
redirect from your previous nginx config without "port_in_redirect 
off;" or your browser did.

Maxim Dounin

More information about the nginx mailing list