0

I am using https and websocket connection for Laravel project. I have setup virtual host like following:

<VirtualHost *:80>
ServerName test.example.com
ServerAdmin test.example.com
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>

<VirtualHost *:443>

ServerAdmin test.example.com
ServerName test.example.com

SSLEngine on
SSLCertificateFile "cert.pem"
SSLCertificateKeyFile "privkey.pem"
SSLCertificateChainFile "chain.pem"

SSLProxyEngine On
ProxyPreserveHost On
ProxyRequests Off

ProxyPass /wss wss://test.example.com:8090/
ProxyPassReverse /wss wss://test.example.com:8090/

DocumentRoot "/var/www/html/laravel/public"
<Directory "/var/www/html/laravel/public">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride all
    Require all granted
</Directory>
</VirtualHost>

But it is showing error in browser:

   WebSocket connection to 'wss://test.example.com:8090/' failed: WebSocket opening handshake timed out

Configuration is like following:

tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      
6426/systemd-resolv
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      
937/sshd
tcp        0      0 {{MY publicIP}}:8090     0.0.0.0:*               LISTEN      
11576/php
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      
19335/mysqld

Can you please help us what can be issue?

Thanks in advance

Test User
  • 1
  • 1
  • 2
  • Hello and welcome to Ask Ubuntu! Can you share the configuration of whatever is listening on port 8090 ? – Daniele Santi Jan 17 '19 at 09:30
  • Yes, but how can I know what is listening to 8090, any command? – Test User Jan 17 '19 at 09:36
  • Please check with `netstat -tlnp` or `ss -tlnp` to show what services are listening (and on which ports). That said, you have configured a `ProxyPass` to _your_ server on port `8090`, it means you want to forward your HTTP(s) request to a known service? Or did you just copy/paste some code from the Internet? – Daniele Santi Jan 17 '19 at 09:44
  • I copied and pasted the code. Actually I do not want to redirect to any. I am directly making connection using url 'wss://test.example.com:8090/'. It was working fine with http means if I reomove configuration for ssl(443) then it is working well. – Test User Jan 17 '19 at 09:59
  • Configuration is like following: tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 6426/systemd-resolv tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 937/sshd tcp 0 0 {{MY publicIP}}:8090 0.0.0.0:* LISTEN 11576/php tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 19335/mysqld tcp6 0 0 :::80 :::* LISTEN 20439/apache2 tcp6 0 0 :::443 :::* LISTEN 20439/a – Test User Jan 17 '19 at 10:02
  • Just to be clear... Are you using Apache at all? If you connect your browser to `wss://test.example.com:8090/` Apache won't be concerned as it listen to ports 80 and 443 (not 8090). What your configuration "says" is that _IF_ you're connecting to `https://test.example.com/` (notice the 's', i.e. port 443), _THEN_ Apache will forward your requests to `wss://test.example.com:8090/`. Nothing more. – Daniele Santi Jan 17 '19 at 10:10
  • Yes, I am using apache webserver. So is it something an issue with weboscket server? – Test User Jan 17 '19 at 10:11
  • Ok, so you're pointing your browser to `https://test.example.com/`, correct? Also, looks like _nothing_ is listening on ports 80 and 443... looks like Apache is not even started... – Daniele Santi Jan 17 '19 at 10:12
  • Yes, I am pointing browser to `https://test.example.com/` Is it something an issue with websocket server? – Test User Jan 17 '19 at 10:14
  • Do you have a valid DNS entry for your IP address against example.com? – s1mmel Jan 17 '19 at 10:48
  • Yes, we have valid DNS entry on server – Test User Jan 17 '19 at 11:03

0 Answers0