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

Remotely is reporting Lost Connection #42

Closed
agottschling opened this issue Jul 3, 2019 · 11 comments
Closed

Remotely is reporting Lost Connection #42

agottschling opened this issue Jul 3, 2019 · 11 comments

Comments

@agottschling
Copy link

Hey all, I installed remotely on my server and decided to try and use Apache for the reverse proxy instead of NGINX, as I already had apache running some stuff. It does seem to work, but when I log in, the dashboard console keeps saying that the connection has been lost and that I need to reload the page to reconnect. Reloading doesn't help, as the same message appears once the page reloads.
I've attached my Apache config below, I tried to mimic the NGINX config as best I could, but maybe I missed something.
Thanks,
Andrew

BEGIN Apache2 CONFIG:

<IfModule mod_ssl.c>
<VirtualHost [<IPs REMOVED.]:443 <IPs REMOVED>:443>
        ServerName remotely.mysite.com
        ServerAdmin webmaster@mysite.com

        ProxyPreserveHost On
        #Proxy Requests to Remotely Server
        <LocationMatch "/">
                ProxyPass http://localhost:5000/ 
                ProxyPassReverse http://remotely.mysite.com/
        </LocationMatch>
        <Location "/BrowserHub">
                ProxyPass http://localhost:5000/
                ProxyPassReverse http://remotely.mysite.com/
        </Location>

        <LocationMatch "/DeviceHub">
                ProxyPass http://localhost:5000/
                ProxyPassReverse http://remotely.mysite.com/
        </LocationMatch>

        <LocationMatch "/RCBrowserHub">
                ProxyPass http://localhost:5000/
                ProxyPassReverse http://remotely.mysite.com/
        </LocationMatch>

        <LocationMatch "/RCDeviceHub">
                ProxyPass http://localhost:5000/
                ProxyPassReverse http://remotely.mysite.com/
        </LocationMatch>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLCertificateFile /etc/apache2/certs/mysite.com/fullchain.pem
SSLCertificateKeyFile /etc/apache2/certs/mysite.com/key.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>
@bitbound
Copy link
Collaborator

bitbound commented Jul 4, 2019

Unfortunately, I have no experience with Apache nor the time to set it up and test.

It sounds like the websocket connection is not successfully upgrading. It does a handshake process first over https, then upgrades to wss.

You'll notice in the Nginx config that there's special handling for the Upgrade and Connection headers. You'll need to replicate that part as well.

I'll keep this open for a bit. Let me know how it goes!

@agottschling
Copy link
Author

agottschling commented Jul 14, 2019

Sorry that it took me so long to get back to this, but I did end up getting it to work. Attached is a stripped down config for Apache2.4 that removes everything personal to my server. Feel free to include it as an option for those who don't want or can't load Ngnix.

<IfModule mod_ssl.c>
<VirtualHost *.443>
        ServerName {FQDN}
        ServerAdmin {Admin Email}
	
	#Forward once Websocket Connection has been upgraded.
	RewriteEngine On
	RewriteCond %{HTTP:Upgrade} =websocket [NC]
	RewriteRule /(.*)           ws://localhost:5000/$1 [P,L]
	RewriteCond %{HTTP:Upgrade} !=websocket [NC]
	RewriteRule /(.*)           http://localhost:5000/$1 [P,L]

	ProxyPreserveHost On
	#Proxy Requests to Remotely Server
	<LocationMatch "/">
		ProxyPass http://localhost:5000/ 
		ProxyPassReverse http://localhost:5000/
	</LocationMatch>
	<Location "/BrowserHub">
		ProxyPass http://localhost:5000/
		ProxyPassReverse http://localhost:5000/
	</Location>

	<LocationMatch "/DeviceHub">
		ProxyPass http://localhost:5000/
		ProxyPassReverse http://localhost:5000/
	</LocationMatch>

	<LocationMatch "/RCBrowserHub">
		ProxyPass http://localhost:5000/
		ProxyPassReverse http://localhost:5000/
	</LocationMatch>

	<LocationMatch "/RCDeviceHub">
		ProxyPass http://localhost:5000/
		ProxyPassReverse http://localhost:5000/
	</LocationMatch>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLCertificateFile {Path to fullchain.pem}
	SSLCertificateKeyFile {Path to key.pem}
	Include /etc/letsencrypt/options-ssl-apache.conf #Change this to wherever your apache options for LE are, or ignore if you don't use LE
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>

Remotely A2.4 Config.conf.txt

@bitbound
Copy link
Collaborator

Awesome! Thanks! I'll include this in the Utilities folder as an example.

@Zeik0s
Copy link

Zeik0s commented Jul 17, 2019

Hey @jay-rad, please put the file in the Utilities folder. Took me quite some time to find the apache sample config. 😉

@bitbound
Copy link
Collaborator

@Zeik0s Sorry! I thought I did, but messed up. I uploaded it now. :)

@Zeik0s
Copy link

Zeik0s commented Jul 23, 2019

@agottschling I tried your config for apache, i am still getting the errors. I am using plain http for testing, can this be the reason?

@agottschling
Copy link
Author

@Zeik0s This config is built for an SSL site. What errors are you gettings?

@Zeik0s
Copy link

Zeik0s commented Jul 23, 2019

Every few seconds a little window pops up with a message "the connection was lost, please reconnect" or something like that. I am currently not in range of the PC i am testing on.

@Zeik0s
Copy link

Zeik0s commented Jul 23, 2019

I know, i commented every ssl related line out, so basically it should be fine. Of course i changed the Port to 80.

@agottschling
Copy link
Author

Another thing to check is if mod_proxy_wstunnel is enabled. If it's not, that would explain why it's not working.

@Zeik0s
Copy link

Zeik0s commented Jul 23, 2019

I haven't, i only enabled mod_proxy and mod_proxy_http. Will try it later, thx a lot.
Edit: it works now and the device is connected.

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

3 participants