Can't figure out nginx location block problem

Tried nginx ML, stackoverflow, and the #nginx IRC channel on freenode to no avail… hoping someone here can help.

My whole nginx conf is here: http://donsbox.com/~dfelicia/conf/

In http://donsbox.com/~dfelicia/conf/sites … nsbox.conf">http://donsbox.com/~dfelicia/conf/sites-enabled/donsbox.conf I have:

    location ~ ^/~(.+?)/private(/.*)?$ {
        auth_basic "Restricted";
        auth_basic_user_file htpasswd;
        alias /home/$1/private_html$2;
        autoindex on;
    }

    location ~ ^/~(.+?)(/.*)?$ {
        alias /home/$1/public_html$2;
        autoindex on;
    }

Elsewhere in the same file I have:

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass phpcgi;
    }

So my /~user/ regex is listed before my .php regex and "wins" so that http://donsbox.com/~dfelicia/ does what I expect. Now I want to be able to run PHP from /~user/, though, and I can't figure out what to add.

i.e. I want this to work: http://donsbox.com/~dfelicia/test.php

I have tried nesting a location block under the /~user/ location, but no luck.

Any help appreciated.

0 Replies

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct