I am trying to setup a Nodejs + Angularjs application on digitalocean. I separated the frontend(angularjs) and backend(nodejs) into two nodejs servers each running on ports 3000 and 4000 respectively. I want the angularjs app to be served on mydomain.com and the backend server to be served via the subdomain api.mydomain.com. My nginx configuration is:
server {
server_name mydomain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $proxy_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3000;
}
}
server {
server_name api.mydomain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $proxy_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:4000;
}
}
The following is the DNS configuration for the droplet:
Type Host Value TTL
A api.mydomain.com directs to IP_ADD_OF_DROPLET 3600
A mydomain.com directs to IP_ADD_OF_DROPLET 1800
NS mydomain.com directs to ns1.digitalocean.com 1800
NS mydomain.com directs to ns2.digitalocean.com 1800
NS mydomain.com directs to ns3.digitalocean.com 1800
mydomain.com is configured to used the 3 digitalocean nameservers (ns_.digitalocean.com)
I need help regarding this, so that the api server is accessible (api.mydomain.com).