Set nginx to only monitor subdirectory

Viewed 14

I'm trying to change nginx config file so that nginx only monitors localhost/test and stops monitoring localhost/.

I tried replacing the default file in /etc/nginx/conf.d/default.conf but I'm getting 404. I basically just changed location / { to location /test {


server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    location /test {
        alias   /usr/share/nginx/html;      
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

I'm unsure why this is not working. I also tried to change listen [::]:80; to listen [::]:80/test; but there I got an error invalid host in "80/test" of the "listen" directive

Edit:

I tried copying the index.html to /usr/share/nginx/html/test/ and changed alias in location to root but then when I navigated to localhost/test I got 403 Forbidden

0 Answers
Related