Why nginx not able to serve sites in different locations? -


i want use nginx host static html located in different path on pc, below configuration:

server {     listen       8080;     server_name  localhost;       location /chatserver {         root /users/xxxx/gitrepo/chatserver/public;         index index.html;     }      location /test {         root /users/xxxx/test/test_site;         index index.html;     } 

the file structure is:

users   |-xxxx     |-gitrepo     |  |-chatserver     |       |-public     |          |- index.html     |-test        |-test_site             |- index.html  

but when access: http://localhost:8080/chatserver or http://localhost:8080/test, nginx responds 404 not found.

if access: http://localhost:8080/, nginx return default nginx welcome page.

why configuration not working?

i think should use alias instead of root.

in example url /chatserver/index.html search /users/xxxx/gitrepo/chatserver/public/chatserver/index.html (note "undesired" chatserver after public!). check nginx's logfiles!

see documentation of root , documentation of alias.


Comments