need help cleaning up user directory and php rules

Edho P Arief edhoprima at gmail.com
Tue Jun 2 01:54:23 MSD 2009


I found this to be working. Should be faster than before but dunno. *shrugs*

Or is there a better way doing this? I'm planning to replace my
lighttpd installation with nginx using this config.

server {
listen 80;
        server mahleetserver.com;
        index index.php;
        client_max_body_size 3m;

        if ($uri ~ ^/~edho/blog) {
                set $err404 /~edho/blog/index.php;
                set $is_custom404 1;
        }

        if ($is_custom404 != 1) {
                set $err404 /404.html;
        }
        error_page 404 $err404;

        #username should only contain these letters, right?
        location ~ /\~([A-Za-z\d\-_\s]+)(.*)$ {
                alias /export/home/$1/public_html$2;
                location ~ \.php {
                        #it'll be rather broken if not done this way
                        location ~ /\~([A-Za-z\d\-_\s]+)(.*)$ {
                                set $ud_user $1; set $ud_file $2;
                                root /export/home/$ud_user/public_html;
                                try_files $ud_file @404;
                                fastcgi_pass php-cgi;
                                fastcgi_index index.php;
                                fastcgi_param SCRIPT_FILENAME
$document_root$ud_file;
                                include fastcgi_params;
                        }
                }
        }

        location / {
                root /var/www/data;
                rewrite ^/wiki/([^?]*)(?:\?(.*))? /w/index.php?title=$1&$2;
                rewrite ^/wiki /w/index.php;
                rewrite ^/edogawaconan/signature.jpg
/edogawaconan/signature.php;
        }
        location ~ \.php$ {
                root /var/www/data;
                try_files $uri @404;
                fastcgi_pass php-cgi;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
                include fastcgi_params;
        }
        location ~ /\.ht {
                deny all;
        }
        location @404 {
                return 404;
        }



-- 
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org





More information about the nginx mailing list