Frontend accessible but backend unreachable from external network in Nginx setup

Hey everyone, I’m having trouble with my Nginx setup. It’s weird because when I access it from the internal network where the Nginx server is, everything works fine. But when I try to use it from outside using my domain (rassd.media), only the frontend loads. I can’t reach any of the backend APIs.

I’ve got a config file set up, but I’m not sure if I’m doing it right. I tried to combine some server blocks and messed with the root directory, but that just broke everything.

Here’s a simplified version of what I’m working with:

server {
    listen 3000;
    server_name example.com;
    root /path/to/frontend;
}

server {
    listen 80;
    server_name mysite.com;
    
    location / {
        proxy_pass http://backend_server;
    }
}

I’m pretty new to Nginx, so I might be making some obvious mistakes. Any help would be awesome! Thanks!

hey mate, looks like a headache. have u tried checking ur firewall? sometimes it blocks external access. also, ensure ur DNS is set right. if that fails, try merging ur server blocks with diff location settings for frontend and backend. good luck!

hmm, interesting problem! have u considered using a reverse proxy setup? it could help route external traffic properly. also, maybe check if ur backend is listening on the correct port? sometimes its the little things that trip us up. what other troubleshooting steps have u tried so far?

Based on your configuration, it seems the issue might be related to how your Nginx is handling requests from external networks. Have you checked your firewall settings? Sometimes, external traffic is blocked by default. Additionally, ensure your domain’s DNS is correctly pointing to your server’s public IP address.

Another potential problem could be in your proxy_pass directive. Make sure the backend_server is reachable and correctly defined. You might want to try specifying the exact IP and port of your backend, like this:

proxy_pass http://127.0.0.1:8080;

Also, consider combining your server blocks and adding appropriate location blocks to handle both frontend and backend requests. This approach often works better for single-domain setups. If you’re still stuck, checking Nginx error logs could provide more insight into what’s going wrong.