I am trying to create a nginx server that can host multiple sites on the same server. I have kept two different directories containing index.html files in the /var/www/ directory.
1st directory : dir1 Containing folder strucuture as : dir1/Folder/app; app directory contains index.html for the site.
2nd directory : dir2 Containing folder strucuture as : dir2/Folder/app; app directory contains index.html for the site.
now inside /etc/nginx/conf.d, created 2 .conf files as test.conf and dev.conf
test.conf :
server {
listen 80 default_server;
server_name mydomain.net;
location /dir1/ {
root /var/www/dir1/PharmacyAdminApp/app;
index index.html index.htm;
try_files $uri $uri/ =404;
}
}
dev.conf
server {
listen 80 default_server;
server_name mydomain.net;
location /dir2/ {
root /var/www/dir2/PharmacyAdminApp1/app;
index index.html index.htm;
try_files $uri $uri/ =404;
}
}
After this I restart the nginx server and visit "mydomain.net:80/dir1" on the browser but I get 404. Can anyone let me know what is the issue?
nginx -t. You have two identical server blocks (which is invalid). What you need is one server block containing the two location blocks. - Richard Smithaliasand notroot. - Richard Smith