Reputation: 430
I have Ubuntu server 16.04 server with nginx install (nginx/1.10.3)
I have only one DNS name energy.mysite.local
Which I need to use for multiple websites.
I have 2 Directories in which I have placed website content
1) /var/www/website/
2) /var/www/web-site/
my sites-available & sites-enabled folders content 2 files
website & web-site
Content for website
server {
listen 443 ssl;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
location /website/ {
alias /var/www/website/;
gzip_static on;
expires max;
add_header Cache-Control public;
autoindex off;
}
server_name energy.mysite.local/website;
location / {
try_files $uri $uri/ =404;
}
}
Content for web-site
server {
listen 443 ssl;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
location /web-site/ {
alias /var/www/web-site/;
gzip_static on;
expires max;
add_header Cache-Control public;
autoindex off;
}
server_name energy.mysite.local/web-site;
location / {
try_files $uri $uri/ =404;
}
}
So that I can able use below website
https://energy.mysite.local/website/1.0.1/src/abc.js
https://energy.mysite.local/web-site/2.0.1/src/abc.js
At present https://energy.mysite.local/web-site/2.0.1/src/abc.js
is working fine.
However https://energy.mysite.local/website/1.0.1/src/abc.js
is giving me 404
page
Any way to get it done?
Upvotes: 1
Views: 87
Reputation: 49672
From your question, the two locations appear to share the same root, in which case the separate location
blocks and alias
directive may not be necessary.
For example:
server {
listen 443 ssl;
server_name energy.mysite.local;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
root /var/www;
gzip_static on;
expires max;
add_header Cache-Control public;
location / {
try_files $uri $uri/ =404;
}
}
Upvotes: 1