Nginx on different server not working

I have the following setup that is working:

Internet --> Firewall --> Raspberry Pi running Let’s Encrypt, nginx and Rocket Chat

My target configuration is:

Internet --> Firewall --> Raspberry Pi running Let’s Encrypt, nginx --> Raspberry Pi running Rocket Chat

So essentially the target is all the same components but with nginx and Rocket Chat running on different servers.

The target configuration IS WORKING when i access Rocket Chat from a client on the same local LAN as both Raspberry Pi servers, however, it IS NOT WORKING when i access it from the Internet via the Firewall.

The nginx configuration is identical apart from the proxy_pass parameter, where one is the local server (working setup) and one is the different server (not working via the internet). I initially looked at my firewall but even opening full access didn’t fix it.

nginx config is:

HTTPS Server

server {
    listen 443 ssl;
    server_name <PUBLIC_URL>;

    error_log /var/log/nginx/rocketchat_error.log;

    ssl_certificate /etc/nginx/certificate.crt;
    ssl_certificate_key /etc/nginx/certificate.key;
    ssl_dhparam /etc/nginx/dhparams.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers <CIPHER STRING>
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 180m;

    location / {
        proxy_pass http://<ROCKETCHAT_URL>:3000/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forward-Proto http;
        proxy_set_header X-Nginx-Proxy true;
        proxy_redirect off;
    }
}

Help!

Issue fixed. For reference i had to remove the hosts file entry on the Rocket Chat Server.

Original (using sample domain from documentation)

127.0.0.1    localhost.localdomain    localhost
127.0.0.1    chat.inumio.com          chat

To this

127.0.0.1    localhost.localdomain    localhost

The hosts file entry remains on the nginx server

All now working as expected