HelloZeroNet / ZeroNet

ZeroNet - Decentralized websites using Bitcoin crypto and BitTorrent network
https://zeronet.io
Other
18.39k stars 2.27k forks source link

"Connection with UiServer Websocket was lost. Reconnecting..." when using reverse proxy on apache #1477

Open ghost opened 6 years ago

ghost commented 6 years ago

Step 1: Please describe your environment

Step 2: Describe the problem:

I tried to access zeronet installed on my server ( debian 9 and apache) with a domain name and https using a reverse proxy. but I get the error ! "Connection with UiServer Websocket lost. Reconnecting... " If I connect directly with the ip of my server without https then I do not have an error.

From my research i found that some people was having the same problem but were using nginx and solved it by changing the virtual host config.

ex: https://www.reddit.com/r/zeronet/comments/4a0vbb/zeronet_redirect_via_nginx/

I don't want to use nginx if possible, I want to solve the problem with apache.

Someone open an issue on the github t but closed it without any explanation.

https://github.com/HelloZeroNet/ZeroNet/issues/495

Steps to reproduce:

I wrote the config for reverse proxy in apache:

<VirtualHost *:443>
ServerName zeronet.xxxxxx.com:443
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/zeronet.xxxxxx.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/zeronet.xxxxx.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLHonorCipherOrder     on
AllowEncodedSlashes On
SSLProxyEngine On
SSLProxyVerify None
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerName Off

ProxyPreserveHost On
ProxyPass      /      http://127.0.0.1:43110/ retry=0
ProxyPassReverse  /     http://127.0.0.1:43110/
ProxyPassReverse /Websocket http://127.0.0.1:43110/
ProxyPassMatch ^/(.*)$ http://127.0.0.1:43110/$1/

<Location "/">
Require all granted
</Location>

</VirtualHost>

Zeronet is a systemd service

[Unit]
Description= Decentralised websites
After=network-online.target
[Service]
Type=simple
User=serveur
Group=serveur
UMask=007
ExecStart=/ZeroNet-master/zeronet.py --tor always --ui_ip "*" --ui_host zeronet.xxxxxx.com --disable_udp
Restart=on-failure
# Time to wait before forcefully stopped.
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target

Zeronet is running fine and the same for apache.

Then connect to https://zeronet.xxxxxx.com

Observed Results:

I can connect and login in zeronet but I don't have any interface and the next warning is showing up: ! "Connection with UiServer Websocket lost. Reconnecting... "

Then nothing happening.

Expected Results:

To not have an error and have an interface.

danimesq commented 6 years ago

@HelloZeroNet @shortcutme

binerf commented 6 years ago

Configuration below works for me:

[...]
        ProxyPreserveHost On
        ProxyPass / http://127.0.0.1:43110/
        ProxyPassReverse / http://127.0.0.1:43110/
        ProxyRequests Off
        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
        RewriteRule .* ws://localhost:43110%{REQUEST_URI} [P]
[...]
danimesq commented 6 years ago

@anoadragon453 The above could also be documented, as guide for when setup a proxy

anoadragon453 commented 6 years ago

Noted, thanks!