Many thanks to the creator himself (Igor Sysoev) for the tips.
The actually good (and works) version:
nginx.conf:
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name 10.1.1.10;
root /srv/http/root;
index index.html index.htm index.php;
location ~ ^/~([^/]+)(/.*.php)$ {
alias /home/$1/public_html$2;
disable_symlinks if_not_owner;
# try_files in here tries "alias$vars", therefore
# pass blank string to test for alias location
try_files "" =404;
include php_params;
}
location ~ ^/~([^/]+)($|/.*)$ {
alias /home/$1/public_html$2;
disable_symlinks if_not_owner;
# similar as above and also test / for index.
try_files "" / =404;
}
location ~ .php$ {
try_files $uri @404;
include php_params;
}
location ~ /. {
deny all;
}
}
}
php_params (because I’m lazy and the configs are easier to read this way):
fastcgi_pass 127.0.0.1:8000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params;
UPDATE: try_files, alias and captures doesn’t seem to work properly. I recommend to use error_page instead for now. There’s no confirmation if it’s a bug yet
Update 2012-07-10: Updated configuration.
Pingback: animeBSD · nginx/mod_userdir: take 3
Pingback: animeBSD · nginx and userdir