-1

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.com: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.com.

Here is my nginx config file:

server {
    listen 80;
    server_name mydomain.com;

    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. Forgive 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!

6
  • Are you sure your config is included in your nginx configuration? Did you see it when running the nginx -T command? Did you check mydomain.com, www.mydomain.com, or both? The config you've shown won't work for the www.mydomain.com 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). Commented Mar 6 at 7:05
  • The nginx configuration file seems to be correct from what I’ve seen in docs, and yes the nginx -t command does come back successful. I tried adding www.mydomain.com in addition to mydomain.com to the server_name block in the config file, but still not working properly. Commented Mar 6 at 11:20
  • 1
    Yes, your configuration seems to be correct. However nginx -t and nginx -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. Run nginx -T to see if your configuration snippet is really included in the full configuration used by nginx. Commented Mar 6 at 11:59
  • Oh gotcha, good call. And yes, running nginx -T does show the configuration I set up for this app/domain... Commented Mar 6 at 13:42
  • 1
    Receiving an nginx welcome page means some other server block is answering your request, but I didn't have any ideas how to debug further, sorry. A silly question, did you reload nginx after adding this configuration? Commented Mar 6 at 14:00

1 Answer 1

0

Ok, 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.com without needing to specify the port.

Thanks for your help @Ivan Shatsky!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.