Search code examples
dockernginxconfigreverse-proxy

Nginx running in Docker unable to proxy requests to local network HyperHDR server


I'm unable to proxy requests via Nginx to a server running on local network. The requests aren't going through and eventually are timed out by the requester.

I'm attempting to call a json-rpc API (HyperHDR), which is incompatible with the Content-Length header set by the requesting piece of software (Homebridge that runs on Node.js), so I'm setting up Nginx as a proxy that drops the incompatible header.

The connection works if I curl the server directly from within and outside the Docker container, but not via Nginx. Not sure if there's something wrong with my nginx.conf? There's nothing in the logs of the receiving end, which is the case with other requests, so it seems the requests are not going through. I can see the requests timing out in the Nginx logs after being proxied (with the correct proxy URL), so the requests do get through to Nginx but for some reason are not going through all the way.

nginx.conf

events {}

http {
  server {
    listen 8080;
    listen [::]:8080;
    error_log /var/log/nginx/error.log debug;

    location /json-rpc {
      proxy_pass http://192.168.1.205:8090/json-rpc;
      proxy_set_header Host $http_host;
    }
  }
}

Dockerfile

FROM nginx:latest
COPY nginx.conf /etc/nginx/conf.d/default.conf

I've triple checked that the IP, port and endpoint specified in the proxy_pass are correct - calling it works with Curl as mentioned.


Solution

  • The issue was related to something to do with the Connection header. Clearing it as shown in this solution fixed the issue.