Alias in Nginx Config

APseudoUtopia apseudoutopia at gmail.com
Sun Jul 26 22:07:28 MSD 2009


Hey list,

How does one create an alias in nginx? Here's my setup:

My web-root is /usr/local/www/main. It's a copy of a SVN repo, so I
cannot manually add any folders in there.
I want to make an alias from domain.com/wiki to /usr/local/www/wiki.
I've tried the following code:

location = /wiki {
alias /usr/local/www/wiki;
}

But this isn't working. nginx is returning a "404" error. Here's the
whole config for the server block:

server {
    set $web_root /usr/local/www/main;

    listen x.x.x.x:443 default accept_filter=httpready;
    server_name domain.tld;
    access_log /var/log/httpd/nginx.access.ssl.log main buffer=4k;
    root $web_root;

    # www redirect
    if ($host ~* www\.(.*)) {
        rewrite ^(.*)$ https://domain.tld$1 permanent;
    }

    ssl on;
    ssl_certificate /usr/local/etc/nginx/ssl.crt;
    ssl_certificate_key /usr/local/etc/nginx/ssl.key;
    ssl_ciphers -ALL:!ADH:!NULL:!aNULL:!eNULL:HIGH;
    ssl_prefer_server_ciphers on;
    ssl_protocols SSLv3 TLSv1;
    ssl_verify_client off;
    ssl_verify_depth 1;
    ssl_session_cache shared:NGXSSL:1m;
    ssl_session_timeout 5m;

    # Wiki
    location = /wiki/ {
        alias /usr/local/www/skittles_wiki/;
    }

    location ~ .*\.php$ {
        try_files $uri /404.html;
        fastcgi_index index.php;
        fastcgi_ignore_client_abort off;
        fastcgi_intercept_errors off;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_read_timeout 10; # sec to wait for php-cgi to return data
        fastcgi_param SCRIPT_FILENAME $web_root$fastcgi_script_name;
        include /usr/local/etc/nginx/fastcgi_params;
    }
}





More information about the nginx mailing list