I have an SSR React Router 7 (framework version) Node.js/Express application that I am trying to wire up to a domain, which is running through Linode. I set up my domain on Linode, and updated nameservers on my domain's registrar to point to Linode.
My RR7 application (living on my Linode Ubuntu 24.04 LTS machine) runs fine, but whenever I npm start
the app, for example, to test that I can access it through my domain, the domain only shows the nginx welcome startup page, and only if I go to www.mydomain:3000 then it does show my app, which does in fact run on port 3000, which makes sense. Just not sure why it’s not working when going directly to mydomain.
Here is my nginx config file:
server {
listen 80;
server_name mydomain;
location / {
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;
}
}
I've tested the nginx config and restarted the nginx server, but still can't get this to work. Five me if this is not enough info, I just didn't want to add too much to the OP, so if more info is needed, will provide. Thanks!
I have an SSR React Router 7 (framework version) Node.js/Express application that I am trying to wire up to a domain, which is running through Linode. I set up my domain on Linode, and updated nameservers on my domain's registrar to point to Linode.
My RR7 application (living on my Linode Ubuntu 24.04 LTS machine) runs fine, but whenever I npm start
the app, for example, to test that I can access it through my domain, the domain only shows the nginx welcome startup page, and only if I go to www.mydomain:3000 then it does show my app, which does in fact run on port 3000, which makes sense. Just not sure why it’s not working when going directly to mydomain.
Here is my nginx config file:
server {
listen 80;
server_name mydomain;
location / {
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;
}
}
I've tested the nginx config and restarted the nginx server, but still can't get this to work. Five me if this is not enough info, I just didn't want to add too much to the OP, so if more info is needed, will provide. Thanks!
Share Improve this question edited Mar 6 at 4:41 Drew Reese 204k18 gold badges245 silver badges273 bronze badges asked Mar 6 at 3:57 LushmoneyLushmoney 52012 silver badges28 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 0Ok, looks I figured it out. In the /etc/nginx/sites-enabled
directory, the default
config file was overriding my app/domain nginx config. I'm unsure why, perhaps because of the default_server
option on the listen
config (no idea if that's why), but disabling that default
config got my site to load directly at mydomain without needing to specify the port.
Thanks for your help @Ivan Shatsky!
nginx -T
command? Did you checkmydomain
,www.mydomain
, or both? The config you've shown won't work for thewww.mydomain
domain since you didn't list it in the server names list, so the default server block will be used for it (see the How Nginx processes a request documentation page). – Ivan Shatsky Commented Mar 6 at 7:05nginx -t
command does come back successful. I tried addingwww.mydomain
in addition tomydomain
to theserver_name
block in the config file, but still not working properly. – Lushmoney Commented Mar 6 at 11:20nginx -t
andnginx -T
are two different commands. The first one only checks the configuration file for correctness, while the second additionally outputs the full configuration as nginx sees it. Runnginx -T
to see if your configuration snippet is really included in the full configuration used by nginx. – Ivan Shatsky Commented Mar 6 at 11:59nginx -T
does show the configuration I set up for this app/domain... – Lushmoney Commented Mar 6 at 13:42