Hi Folks,
I am new to digital ocean platform and nginx, I have setup a droplet which serves an angular app seamlessly, however I want to serve multiple angular apps from one digital-ocean droplet based on URL/path.
for an example
abc.com/app1 -----> ~/app1/index.html abc.com/app2 -----> ~/app2/index.html
and so on.
Please refer following configuration I have for my sites-available/abc.com
server {
root /home/alok/abc-web;
index index.html index.htm index.nginx-debian.html;
server_name abc.one www.abc.one;
try_files $uri $uri/ /index.html;
location /app1/ {
alias /home/alok/abc-web/app1/dist/;
try_files $uri /index.html;
}
location /app2/ {
alias /home/alok/abc-web/app2/dist/;
try_files $uri /index.html;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/abc.one/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/abc.one/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = abc.one) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name abc.one www.abc.one;
return 404; # managed by Certbot
}
I have replaced abc.com with actual domain name I used.
I understand its more of an Nginx config issue than a digital-ocean droplet issue.
Thanks in advance.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Hi there,
I think that the Ningx config looks good, you just need to update the locations a little bit to:
Note that after each Nginx config change, you need to restart/reload the Nginx service.
Let me know how it goes! Best, Bobby