original filename not getting to 403 error page

Igor Sysoev is at rambler-co.ru
Sat Jan 13 10:40:07 MSK 2007


On Sat, 13 Jan 2007 ianevans at digitalhit.com wrote:

> Hi there...just checking if I have my 403 error call set up incorrectly.
>
> I have my 403 set up with:
>
> error_page 403 /dhe403.shtml;
>
> and the referers checked with:
>
> valid_referers none  blocked  *.digitalhit.com digitalhit.com
> *.othersite.com;
> if ($invalid_referer) {
> return   403;
> }
>
> This is inside the location for the static files, which are served
> directly by nginx.
>
> When the 403 happens the php variable (.shtml is treated as .php by the
> Apache backend) $_SERVER["REQUEST_URI"] is coming back as "/dhe403.shtml"
> instead of the image file being requested.
>
> Oddly enough, the 404 error page is getting the $_SERVER["REQUEST_URI"] as
> the filename being requested, so its working as expected
>
> Any reason why the 403 page's $_SERVER["REQUEST_URI"] is wrong but it's
> working for the 404? Is the original requested filename not getting passed
> back to Apache for some reason?

The error_page directive changes the nginx internal request URI.
If you do not rewrite URI part in the proxy_pass directive, then nginx will
pass the original URI to backend:

    location / {
-      proxy_pass  http://backend/;
+      proxy_pass  http://backend;
        ...
    }

    location  /static/  {
        error_page  403 /dhe403.shtml;
        ...
    }


Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list