currently I'm using the nginx to serve the static files of my API docs (mywebsites.com), I want to add another website : mywebsites.com/subwebsite.
so I edited the nginx config file to serve both of them :
server {
listen 0.0.0.0:80;
server_name mywebsite.com;
client_max_body_size 1m;
access_log /var/log/nginx/error.log;
error_log /var/log/nginx/static.log;
#location ~ /\.git {
# deny all;
#}
location /subwebsite {
root /home/api/portal/build;
index index.html index.htm;
try_files $uri $uri/ =404;
}
location / {
root /home/api/application/public;
index index.html index.htm;
try_files $uri $uri/ =404;
}
#sendfile off;
}
The problem is when I try to access the new website : mywebsite.com/subwebsite .. I got 404 not found.
And when I try to change the current server to forward to the new subwebsite (instead of adding location /subwebsite, I change the root for location /) it works.
the original file:
server {
listen 0.0.0.0:80;
server_name mywebsite.com;
client_max_body_size 1m;
access_log /var/log/nginx/error.log;
error_log /var/log/nginx/static.log;
location ~ /\.git {
deny all;
}
location ~ {
root /home/api/application/public;
index index.html index.htm;
try_files $uri $uri/ =404;
}
sendfile off;
}
What I'm missing here ?
Thanks in advance