Many thanks to the creator himself (Igor Sysoev) for the tips.
The actually good (and works) version:
nginx.conf:
user http;
worker_processes 8;
daemon off;
error_log /var/log/nginx/error.log debug;
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;
# try_files in here tries "alias$vars"
error_page 404 = @404;
include php_params;
}
location ~ /~([^/]+)($|/.*)$ {
alias /home/$1/public_html$2;
error_page 404 = @404;
}
location ~ \.php$ {
try_files $uri @404;
include php_params;
}
location ~ /\.ht {
deny all;
}
location @404 { return 404; }
error_page 404 /404.html;
}
}
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
Pingback: animeBSD · nginx/mod_userdir: take 3
Pingback: animeBSD · nginx and userdir