NGINX Reverse Proxy Flycast 502 Error

I have a NGINX server deployed on Fly which proxies to a Node server I also deployed on Fly.

I am getting this error:
[error] 310#310: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream

Here’s the nginx.conf:

location / {
  root /usr/share/nginx/html;
  try_files $uri /index.html;
  sendfile on;
  tcp_nopush on;

location /api/ {
  proxy_pass http://backend.flycast:8080/;
  proxy_set_header X-Forwarded-Host $http_host;
  proxy_ssl_name $host;
  proxy_ssl_server_name on;

And my Node server has this in fly.toml:

  internal_port = 8080
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

I fixed the problem by changing the port in proxy_pass to 80 instead of 8080.
I also removed proxy_ssl_name and proxy_ssl_server_name and it still worked.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.