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

Socket.io can't be used with Reverse Proxy in serveronly mode #1934

Closed
Legion2 opened this issue Feb 16, 2020 · 1 comment
Closed

Socket.io can't be used with Reverse Proxy in serveronly mode #1934

Legion2 opened this issue Feb 16, 2020 · 1 comment

Comments

@Legion2
Copy link
Contributor

Legion2 commented Feb 16, 2020

Platform: Raspberry Pi 3 using docker as server (f9d9ff1a354d), Chrome on Windows 10 as client

Node Version: 12, the version in the latest(f9d9ff1a354d) docker image

MagicMirror Version: v2.10.1

Description: I want to use Magic Mirror behind a Reverse proxy so I can access it via a sub path in the url as http://localhost/magic-mirror/. I setup a Preserve Proxy so I can access http://localhost/magic-mirror/, but it only shows a blackscreen. The console log of the browser shows that the socket.io.js could not be loaded. That's because it's loaded from an absolute path in index.html (src="/socket.io/socket.io.js"). All other scripts are loaded without problem, because they are using relative paths.

I removed the / from the path in the index.html but socket.io also uses absolute path somewhere else. So this simple change did not solve the whole problem.

Steps to Reproduce:

  1. Start the MagicMirror docker container
  2. setup Reverse Proxy using e.g. apache2:
ProxyPass "/magic-mirror/" "http://localhost:8080/"
ProxyPassReverse "/magic-mirror/" "http://localhost:8080/"
ProxyPreserveHost On
  1. open http://localhost/magic-mirror/

Expected Results: open http://localhost/magic-mirror/ should show magic mirror

Actual Results: Blackscreen, chrome console log:

GET http://localhost/socket.io/socket.io.js net::ERR_ABORTED 404 (Not Found)
main.js:455 Initializing MagicMirror.
...

the url should be http://localhost/magic-mirror/socket.io/socket.io.js

Configuration: default docker config

Additional Notes: I want to use Magic Mirror behind a Reverse Proxy, because then I can better manage all exposed services and protect them with password and TLS. The localhost urls are only used for simplification.

@Legion2
Copy link
Contributor Author

Legion2 commented Feb 18, 2020

I found a fix for the problem and can provide a PR. But we have to discuss the solution as there could be conflicts with the url handling and other modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant