Welcome! Log In Create A New Profile

Advanced

Re: Shouldn't this trigger an nginx 404?

March 26, 2009 03:25AM
On Wed, Mar 25, 2009 at 09:29:00PM -0700, Michael Shadle wrote:

> i changed a couple paths to mask the real stuff but this should give
> you an idea.
>
> This is some fastcgi stuff. I would think the intercept_errors one is
> what I want...?
>
> Is there an issue with the header being sent (in the middle of the debug log)
>
> fastcgi_ignore_client_abort on;
> fastcgi_intercept_errors on;
> fastcgi_buffers 32 8k;
> fastcgi_index index.php;
>
> here's the server block:
>
> server {
> listen 443;
> server_name foo.com;
> root /home/software/web/foo.com;
> index index.php index.html;
> ssl on;
> ssl_certificate mycert.pem;
> ssl_certificate_key mykey.key;
> ssl_protocols SSLv3 TLSv1;
> include /etc/nginx/expires.conf;
> location /files {
> rewrite ^/files/(.*) /foo.php?file=$1 last;
> }
> location / {
> if (!-e $request_filename) {
> rewrite ^(.*) /bar.php?slug=$1 last;
> }
> }
> location ~ \.php$ {
> fastcgi_pass 127.0.0.1:11021;
> }
> }
> }

Besides "fastcgi_intercept_errors on" you also need

error_page 404 /404.html;

nginx does not intercept an error if there is no custom handler for it:
it does not show its default pages. This allows to intercept some errors,
while passing others as are.

Also, two ways to omit rewrites:

location / {
try_files $uri /bar.php?slug=$uri;
}

location ~ ^/files/(.*) {
fastcgi_pass 127.0.0.1:11021;
fastcgi_param SCRIPT_FILENAME /foo.php;
fastcgi_param QUERY_STRING file=$1;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:11021;
fastcgi_param SCRIPT_FILENAME /path/to$uri;
fastcgi_param QUERY_STRING $query_string;
}

or

location / {
try_files $uri @bar;
}

location ~ ^/files/(.*) {
fastcgi_pass 127.0.0.1:11021;
fastcgi_param SCRIPT_FILENAME /path/to/foo.php;
fastcgi_param QUERY_STRING file=$1;
}

location @bar;
fastcgi_pass 127.0.0.1:11021;
fastcgi_param SCRIPT_FILENAME /path/to/bar.php;
fastcgi_param QUERY_STRING slug=$request_ur;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:11021;
fastcgi_param SCRIPT_FILENAME /path/to$uri;
fastcgi_param QUERY_STRING $query_string;
}


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

Shouldn't this trigger an nginx 404?

mike March 24, 2009 08:36PM

Re: Shouldn't this trigger an nginx 404?

Igor Sysoev March 25, 2009 11:35AM

Re: Shouldn't this trigger an nginx 404?

mike March 26, 2009 12:29AM

Re: Shouldn't this trigger an nginx 404?

Igor Sysoev March 26, 2009 03:25AM

Re: Shouldn't this trigger an nginx 404?

mike March 26, 2009 04:13AM

Re: Shouldn't this trigger an nginx 404?

Igor Sysoev March 26, 2009 05:17AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 109
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready