I have multiple domain names pointing to the same node server using nginx. The node server needs to know which domain it is running the current request for. How do I pass this information through.
An nginx setup for each domain:
server {
listen 443;
ssl on;
ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;
server_name mydomain;
location / {
proxy_pass http://localhost:3010;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Node runs in upstart but that is probably irrelevant. How do I run node on the command line so that I can pick up mydomain
as an environment variable. I currently run as:
NODE_PATH=./src NODE_ENV=production PORT=3010 APIPORT=3012 /node/path/node bin/server.js >> /log/path/mydomain.log 2>&1