By Stuart BRown
Hi,
I have followed the below tutorials to get set up with an Ubuntu 16.04 server running NodeJS, NGINX, and with SSL set up via Let’s Encrypt: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04 https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04 https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04 https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04
All works pretty well in that my own domain now points to my droplet and I can connect under SSL and get to the NGINX Welcome page.
However I have deployed my express app to /home/stuart/<project-name> but I cannot access its home route (‘/’). Locally the app runs at port 3000
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
In NGINX my sites-available/defaults has a server block
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name <mydomain> www.<mydomain>; //the actual file has my domain name in
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
My sites-enabled/defaults has a server block
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name <mydomain> www.<mydomain>;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
Do I need to just clone my express app into /var/www/html and modify the defaults in sites-available and sites-enabled to root /var/www/html/<appname>;?
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!
ok solved this. Just had to add
proxy_pass http://127.0.0.1:3000;
in the location object of the server block
This comment has been deleted
i used npx express-generator to bootstrap my Express app and can’t figure out how to get it to work on my droplet! 😡
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.