I have an Ubuntu 16.04 Azure VM, with a basic node.js managed by PM2. I have all of my DNS setup to hit the server and firewall open for TCP on 80. I am trying to make this app available via reverse proxy with Nginx. However, I continue to get nothing but the following welcome screen when I navigate my domain...
Here my is simple server.js
express app...
let express = require('express');
let app = express();
app.set('port', 5001);
app.use(express.static('.'));
app.get('/ping', function(req, res) {
res.status(200).send('pong'); // sanity check
});
app.all('/*', function (req, res) {
res.sendFile(`${process.cwd()}/index.html`) // react SPA
});
app.listen(app.get('port'), function () {
console.log(`server listening on port ${app.get('port')}`);
});
Nginx config located at /etc/nginx/sites-available/default
server {
listen 80;
server_name MyBoughtDomain.com;
location / {
proxy_pass http://localhost:5001;
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;
}
}
I have PM2 running this just fine, with the following returning exactly as I'd expect...
curl localhost:5001/ping
// pong
Is there something glaringly wrong with my sites-available
config? Does it matter where I dump my files if server.js
is listening on localhost:5001
? I've followed handfuls of tutorials online and all have simple examples with these exact steps working A-OK.
The common denominator though, given all the articles, is they aren't hosting a VM on Azure. Would Azure's infrastructure be causing some oddness here in any way? I can't imagine it would, but I'm at a total loss and can't think of anything else. I can't get this welcome screen out of my sight...
References
- How To Set Up a Node.js Application for Production on Ubuntu 16.04
- Configure Nginx as a web server and reverse proxy for Nodejs application on AWS Ubuntu 16.04 server
via scniro
No comments:
Post a Comment