Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Action Cable does not work with custom self hosted domains via reverse proxy #1505

Open
EsdrubalMagano opened this issue Nov 26, 2024 · 6 comments
Labels
🐛 Bug Something isn't working ⚙️ Config

Comments

@EsdrubalMagano
Copy link

EsdrubalMagano commented Nov 26, 2024

Describe the bug
When adding a new account I get the following error:
image
In console I see the following error:
image

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'https://maybe.example.com/accounts/new
  2. Click on 'add new investment/bank/etc'
  3. See error

Expected behavior

What version of Maybe are you using?
Self-hosted Version: v0.2.0-alpha.2 using docker

What operating system and browser are you using?
Windows 11 and Brave

Screenshots / Recordings

Additional context
I already tried to rebuild the docker container, no luck, also tried to disable Brave Adblocker.

@EsdrubalMagano EsdrubalMagano added the 🐛 Bug Something isn't working label Nov 26, 2024
@zachgoll
Copy link
Collaborator

@EsdrubalMagano this appears to be an app configuration issue as it is not reproducible via the issue description.

Could you provide some more info and/or logs?

@zachgoll zachgoll added ℹ️ Needs info Further information is requested and removed 🐛 Bug Something isn't working labels Nov 27, 2024
@EsdrubalMagano
Copy link
Author

Docker configuration look's good, I see these errors on docker logs:

maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] rack (3.1.8) lib/rack/sendfile.rb:114:in call' maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] railties (7.2.2) lib/rails/engine.rb:535:in call'
maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] puma (6.4.3) lib/puma/configuration.rb:272:in call' maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] puma (6.4.3) lib/puma/request.rb:100:in block in handle_request'
maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] puma (6.4.3) lib/puma/thread_pool.rb:378:in with_force_shutdown' maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] puma (6.4.3) lib/puma/request.rb:99:in handle_request'
maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] puma (6.4.3) lib/puma/server.rb:464:in process_client' maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] puma (6.4.3) lib/puma/server.rb:245:in block in run'
maybe-app-1 | [9917228f-adb2-48fe-8d48-e079474a6a8c] puma (6.4.3) lib/puma/thread_pool.rb:155:in `block in spawn_thread'
maybe-app-1 | I, [2024-11-27T13:43:32.878857 #1] INFO -- : [e040affc-4357-40d6-873b-8e9882a9f97e] Started GET "/cable" for 149.88.20.130 at 2024-11-27 13:43:32 +0000
maybe-app-1 | I, [2024-11-27T13:43:32.880057 #1] INFO -- : [e040affc-4357-40d6-873b-8e9882a9f97e] Started GET "/cable" [WebSocket] for 149.88.20.130 at 2024-11-27 13:43:32 +0000
maybe-app-1 | E, [2024-11-27T13:43:32.880132 #1] ERROR -- : [e040affc-4357-40d6-873b-8e9882a9f97e] Request origin not allowed: https://maybe.example.com
maybe-app-1 | E, [2024-11-27T13:43:32.880160 #1] ERROR -- : [e040affc-4357-40d6-873b-8e9882a9f97e] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: upgrade, HTTP_UPGRADE: websocket)
maybe-app-1 | I, [2024-11-27T13:43:32.880185 #1] INFO -- : [e040affc-4357-40d6-873b-8e9882a9f97e] Finished "/cable" [WebSocket] for 149.88.20.130 at 2024-11-27 13:43:32 +0000
maybe-app-1 | I, [2024-11-27T13:44:33.047684 #1] INFO -- : [7adb18fa-9e4e-4806-9338-a9339ce0443a] Started GET "/cable" for 149.88.20.130 at 2024-11-27 13:44:33 +0000
maybe-app-1 | I, [2024-11-27T13:44:33.049446 #1] INFO -- : [7adb18fa-9e4e-4806-9338-a9339ce0443a] Started GET "/cable" [WebSocket] for 149.88.20.130 at 2024-11-27 13:44:33 +0000
maybe-app-1 | E, [2024-11-27T13:44:33.050671 #1] ERROR -- : [7adb18fa-9e4e-4806-9338-a9339ce0443a] Request origin not allowed: https://maybe.example.com
maybe-app-1 | E, [2024-11-27T13:44:33.051367 #1] ERROR -- : [7adb18fa-9e4e-4806-9338-a9339ce0443a] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: upgrade, HTTP_UPGRADE: websocket)
maybe-app-1 | I, [2024-11-27T13:44:33.051996 #1] INFO -- : [7adb18fa-9e4e-4806-9338-a9339ce0443a] Finished "/cable" [WebSocket] for 149.88.20.130 at 2024-11-27 13:44:33 +0000

But it's strange, because I have WebSockets in Nginx config:

location / {
    proxy_pass http://127.0.0.1:3001;
    proxy_http_version 1.1;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host:$server_port;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Server $host;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

@zachgoll
Copy link
Collaborator

zachgoll commented Nov 27, 2024

@EsdrubalMagano does this configuration work?

location / {
    proxy_pass http://localhost:3001;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

This configuration has been working for most self-hosters. I don't think you need to add the extra websockets config.

I'm going to close this out as it is not something we can do anything about with the Maybe app.

@EsdrubalMagano
Copy link
Author

Same error, and docker logs:

maybe-app-1 | I, [2024-11-27T14:04:32.633800 #1] INFO -- : [4d1eaa0c-5674-465d-8944-a2abed286843] Started GET "/cable" for 149.88.20.130 at 2024-11-27 14:04:32 +0000
maybe-app-1 | I, [2024-11-27T14:04:32.636312 #1] INFO -- : [4d1eaa0c-5674-465d-8944-a2abed286843] Started GET "/cable"[non-WebSocket] for 149.88.20.130 at 2024-11-27 14:04:32 +0000
maybe-app-1 | E, [2024-11-27T14:04:32.637236 #1] ERROR -- : [4d1eaa0c-5674-465d-8944-a2abed286843] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: close, HTTP_UPGRADE: )
maybe-app-1 | I, [2024-11-27T14:04:32.638163 #1] INFO -- : [4d1eaa0c-5674-465d-8944-a2abed286843] Finished "/cable"[non-WebSocket] for 149.88.20.130 at 2024-11-27 14:04:32 +0000

@zachgoll
Copy link
Collaborator

@EsdrubalMagano looking into this a bit further, this may actually be something we could set via ENV vars so that custom domains work properly:

config.action_cable.allowed_request_origins = ["https://maybe.example.com"]

Reopening and renaming the issue so we can get some more eyes on it.

@zachgoll zachgoll reopened this Nov 27, 2024
@zachgoll zachgoll changed the title Bug: Error when adding new account Bug: Action Cable does not work with custom self hosted domains via reverse proxy Nov 27, 2024
@zachgoll zachgoll added ⚙️ Config 🐛 Bug Something isn't working and removed ℹ️ Needs info Further information is requested labels Nov 27, 2024
@EsdrubalMagano
Copy link
Author

EsdrubalMagano commented Nov 27, 2024

I also changed the default ports in the docker compose in case that could related in some way:

    ports:
      - 3001:3001
    environment:
      PORT: 3001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working ⚙️ Config
Projects
None yet
Development

No branches or pull requests

2 participants