I'm a nginx noob and am looking for some help (my nginx config is below). I'm attempting to put nginx in front of a PHP application that currently uses Apache.
my "/" location is working properly. Nginx is serving the static files and proxying to apache for the dynamic content.
I'm now trying to make "UserDir" functionality work properly. I need http://example.com/~mmattax/ to use /home/mmattax/public_html as the document root and proxy to apache for the dynamic content. My attempt below seems to proxy everything to apache; nginx does not seems to be using the correct document root.
I'm also looking for any tips on the config below. Thanks.
location ~ ^/~(.+?)(/.*)?$ {
root /home/$1/public_html;
index index.php;
autoindex on;
try_files $uri $uri/ @proxy;
}
location / {
root /home/myapp/www;
index index.php;
try_files $uri $uri/ @proxy;
}
location @proxy {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
}
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
}
I found this over on the nginx wiki