Auth and PHP

mike mike503 at gmail.com
Sun Sep 7 23:13:51 MSD 2008


Example here of a password protected dir that processes PHP:

http://michaelshadle.com/2008/08/17/nginx-wordpress-redux/

Note that the issue is probably due to the order of location {} blocks
and such. That's what got me. Also how you set them up (with the
appropriate ^~ and ~ and stuff)

As always, I also give my two cents about ways to make the config file cleaner:

These three things can be set globally on the http {} level:

fastcgi_index index.php;
fastcgi_intercept_errors  on;
fastcgi_param  SCRIPT_FILENAME /home/user/public_html$fastcgi_script_name;

Remember for SCRIPT_FILENAME you can use this and simplify your life
(unless for some reason you have to hardcode it)

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

The only thing you need per server {} or location {} is:

location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
}

No need to define anything special or use include 'fastcgi_params' for
each location. It can all be done globally (just being anal retentive)

On Sun, Sep 7, 2008 at 6:19 AM, David <mishy.cth at gmail.com> wrote:
> Hello,
>
> I am having a hard time trying to password protect a directory containing
> PHP files.
> Whenever I access www.domain.com/forums/admin/ I get a 404 error.
> I have tried setting a fastcgi_param  SCRIPT_FILENAME in my forums/admin
> location section and that doesn't work either. I have also been moving around
> location sections incase there was a correct processing order that I
> was missing out on but I couldn't get it to change anything.
>
> Any help would be greatly appreciated.





More information about the nginx mailing list