Not existant files passed to php backend

Delta Yeh delta.yeh at gmail.com
Wed Aug 20 20:24:29 MSD 2008


Does the following config work?
If it does, is it reasonable in your opinition?

location / {

if($geo ) {
    proxy_pass http://upstream2;
}

 if( $request_uri ~  \.css$){
   expire 3d;
}

if( $request_uri ~ \.gif$ ) {
  expire 1d;
}
...
if( $request_uri ~ \.jpeg$ ) {
  expire 2d;
}

if( $request_uri ~ /admin/ ) {
    auth_basic            "Restricted";
    auth_basic_user_file  conf/htpasswd;

}


proxy_pass http://upstream;

}

2008/8/21 Igor Sysoev <is at rambler-co.ru>:
> On Thu, Aug 21, 2008 at 12:01:42AM +0800, Delta Yeh wrote:
>
>> Does multiple complex directive inside "if" block  impact the performance ?
>> If so, how much ?
>
> No, they does not impact the perfomance, but they has many limits
> and drawbacks.
>
>> 2008/8/20 Igor Sysoev <is at rambler-co.ru>:
>> > On Wed, Aug 20, 2008 at 05:29:00PM +0200, Roxis wrote:
>> >
>> >> On Wednesday 20 August 2008, Reinis Rozitis wrote:
>> >> > > it is expected
>> >> > >
>> >> > > if you don't like php's 404 page
>> >> > > set fastcgi_intercept_errors to on
>> >> >
>> >> > I see.
>> >> >
>> >> > Just switching from lighty where the default behaviour is first to check
>> >> > the local file ( lighttpd has an extra setting 'check-local' where you can
>> >> > specify to look for the file on local disk rather than blindly forwarding
>> >> > to request on the fastcgi backend )
>> >> >
>> >> > Although this is handy in case of remote fastcgi backends isnt the majority
>> >> > setups where the nginx and php (and other fastcgi processes) are on the
>> >> > same box? And as the php is the slowest component wouldnt it be more
>> >> > efficient from the performance point of view for the nginx throw the error
>> >> > first rather than intercepting the error later (and maybe add a
>> >> > setting/feature (mimic to lighty) to disable the local file check)..
>> >> >
>> >> > Anyways thx for the hint.
>> >> >
>> >> > rr
>> >>
>> >> you can use ngx_http_rewrite_module
>> >>
>> >> if (!-f $request_filename) {
>> >>     return 404;
>> >> }
>> >> fastcgi_pass ...
>> >>
>> >> but it's not recommended
>> >
>> > Although I generally do not recommend to use "if (!-f $request_filename)",
>> > it's mostly related to complex directive inside "if" block, something like:
>> >
>> >      if (!-f $request_filename) {
>> >          fastcgi_pass ...
>> >      }
>> >
>> > but simple "return 404" in "if" block is OK.
>> >
>> >
>> > --
>> > Igor Sysoev
>> > http://sysoev.ru/en/
>> >
>> >
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>





More information about the nginx mailing list