Rails turbo_stream_from does not connect in fly.io environment

Ok, looks like I’ve got it working now.

While setting the internal address instead of the flycast one, I also further played around with the nginx config and before deploying the rails update with the internal address, I deployed the following nginx config change and it seems to work now.

location /cable {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Ssl on; # Optional
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

    proxy_pass http://$rails;
  }

  location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Ssl on; # Optional
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;

    proxy_redirect off;

    proxy_read_timeout 120;
    proxy_connect_timeout 120;
    proxy_send_timeout 120;

    proxy_pass http://$rails;
  }

Apparently, proxy_http_version 1.1; was key to making the cable connection work and it was missing in my config.

Interestingly though, I can’t leave out the lines before proxy_http_version 1.1; because if I do, I see a lot of [ActionDispatch::HostAuthorization::DefaultResponseApp] Blocked hosts: myapp-rails-staging.flycast errors in the rails logs.

Hey @rubys , thank you very much for helping me out with this!