nginx/mod_userdir: take 4

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

This entry was posted in software, tnt and tagged . Bookmark the permalink. Follow any comments here with the RSS feed for this post.

2 Responses to nginx/mod_userdir: take 4

  1. Pingback: animeBSD · nginx/mod_userdir: take 3

  2. Pingback: animeBSD · nginx and userdir

Leave a Reply

Your email is never published nor shared. Required fields are marked *

*

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>