External Redirect when expecting internal redirect

Francis Daly francis at daoine.org
Sun Mar 10 12:57:09 UTC 2013


On Sun, Mar 10, 2013 at 01:30:22PM +0100, Thomas Glanzmann wrote:

Hi there,

> Depending on the subnet accessing either rewrite internally to a cgi
> script or to a static Website. For the cgi script that works perfectly
> fine, for the static web site nginx always does a HTTP 301 instead of an
> internal rewrite.

What do you expect the user to see with the static web site? As in,
what content do you wish nginx to return?

>                 location /blank {
>                         internal;
>                         autoindex on;
>                         autoindex_exact_size off;
>                 }
> 
>                 location = / {
>                         rewrite ^ /$site last;
>                 }

So, the request is for "/", nginx does a rewrite (internal) to "/blank",
and that is a directory, so nginx does a redirect (external) to "/blank/".

That's pretty much what I expect to happen.

(Then the browser requests /blank/ and gets rejected because the
location{} is marked "internal".)

> I would like to acomplish that when 127.0.0.0/8 access the webserver the client
> is internally redirected to eva.pl, which works, but if another ip address
> access a website from static files is displayed, which works was well if I drop
> the 'internal' keyword from location /blank but not using an internal redirect.
> 
> What do I have to change in order to make the internal rewrite for the files
> work?

You can use an internal rewrite to a file, provided that you actually
rewrite to a file. Here, you rewrite to a directory without including
the trailing /.

I confess I'm not sure what it is that you want to do.

Possibly setting the default in the map to "blank/" will help?

But you will have to decide what the next step for the user is.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list