Thursday, 13 July 2017

Nginx - alias vs root


Consider the following nginx config snippet:

server {
    listen       80;
    server_name  my_server;

    location /foo {
        root         /var/html;
        autoindex on;
        allow all;
    }
    location /bar {
        alias         /var/html;
        autoindex on;
        allow all;
    }
}

The root directive will map a request for http://myserver.stack1.com/foo to a directory /var/html/foo

The alias directive will map a request for http://myserver.stack1.com/bar to a directory /var/html  
(i.e. The rested URI is not appended to the file system location)



No comments:

Post a Comment