Hi,
I have a domain (referenced as mydomain.com) and I’m trying to run a couple of node apps on it like mydomain.com/node.
When I start the node server and og to mydomain.com/node, I get “Cannot GET /node”.
The node app is in the following folder: var/www/mydomain.com/node
My conf file in ‘sites-available’ for nginx is this:
server {
server_name www.mydomain.com;
return 301 $scheme://mydomain.com$request_uri;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/mydomain.com/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name mydomain.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location /node {
proxy_pass http://localhost:3000;
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;
}
}
Can you please tell me what I’m doing wrong?
Thanks
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!
Try adding the following line after location /node {:
rewrite /node/(.*) /$1 break;
and reloading nginx.
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.