Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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;
}
share|improve this question
add comment

1 Answer 1

I found this over on the nginx wiki

location ~ ^/~(.+?)(/.*)?$ {
 alias /home/$1/public_html$2;
 index  index.html index.htm;
 autoindex on;
}
share|improve this answer
    
This is the same regex that I'm using, but I'm wanting to proxy dynamic content. –  mmattax Nov 1 '11 at 22:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.