2017-03-13 5 views
2

Ich habe einen PHP-Websocket-Server ausgeführt, aber ich möchte über https eine Verbindung herstellen. Das ist mein JS: var conn = new WebSocket('wss://81.169.228.159:3671/wss2');PHP WebSocket auf SSL mit proxy_wsTunnel - Apache

Und das ist meine Apache-Konfiguration:

ProxyPass /wss2/ ws://domain:3671/

Ich habe proxy und proxy_wstunnel aktiviert.

Also, was mache ich falsch?

ERROR LOG:

[Mon Mar 13 04:38:04.228450 2017] [mpm_prefork:notice] [pid 6683] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 04:38:04.228471 2017] [core:notice] [pid 6683] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 12:42:39.475641 2017] [:error] [pid 12432] [client 195.169.9.201:8546] script '/var/www/html/luukwuijster.io/phpinfo.php' not found or unable to stat 
[Mon Mar 13 12:56:25.370986 2017] [mpm_prefork:notice] [pid 6683] AH00169: caught SIGTERM, shutting down 
[Mon Mar 13 12:56:26.539948 2017] [mpm_prefork:notice] [pid 26932] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 12:56:26.539972 2017] [core:notice] [pid 26932] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 13:06:36.280229 2017] [mpm_prefork:notice] [pid 26932] AH00169: caught SIGTERM, shutting down 
[Mon Mar 13 13:06:37.473220 2017] [mpm_prefork:notice] [pid 27256] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 13:06:37.473248 2017] [core:notice] [pid 27256] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 13:19:52.144983 2017] [mpm_prefork:notice] [pid 27256] AH00169: caught SIGTERM, shutting down 
[Mon Mar 13 13:19:53.235045 2017] [mpm_prefork:notice] [pid 27775] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 13:19:53.235083 2017] [core:notice] [pid 27775] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 13:22:21.467607 2017] [mpm_prefork:notice] [pid 27775] AH00169: caught SIGTERM, shutting down 
[Mon Mar 13 13:22:22.618416 2017] [mpm_prefork:notice] [pid 27911] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 13:22:22.618455 2017] [core:notice] [pid 27911] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 13:28:08.356148 2017] [mpm_prefork:notice] [pid 27911] AH00169: caught SIGTERM, shutting down 
[Mon Mar 13 13:28:09.546926 2017] [mpm_prefork:notice] [pid 28540] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 13:28:09.546964 2017] [core:notice] [pid 28540] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 13:35:26.856446 2017] [mpm_prefork:notice] [pid 28540] AH00169: caught SIGTERM, shutting down 
[Mon Mar 13 13:35:28.532498 2017] [mpm_prefork:notice] [pid 29153] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 13:35:28.532541 2017] [core:notice] [pid 29153] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 13:46:19.084561 2017] [ssl:error] [pid 29170] [client 208.93.152.93:54712] AH02042: rejecting client initiated renegotiation 
[Mon Mar 13 13:57:14.410892 2017] [mpm_prefork:notice] [pid 29153] AH00169: caught SIGTERM, shutting down 
[Mon Mar 13 13:57:16.465381 2017] [mpm_prefork:notice] [pid 29927] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations 
[Mon Mar 13 13:57:16.465424 2017] [core:notice] [pid 29927] AH00094: Command line: '/usr/sbin/apache2' 
[Mon Mar 13 14:00:03.312882 2017] [:error] [pid 29936] [client 81.169.228.159:33706] PHP Notice: Undefined index: text in /var/www/html/luukwuijster.io/slack/cronofy/huiswerk.php on line 9 
+0

Zertifikate sind domänenbasiert und können nicht mit IP-Adressen arbeiten. –

+0

Ich habe es jetzt zu meiner Domain geändert. Und es funktioniert immer noch nicht –

+0

Haben Sie Ihr Fehlerprotokoll überprüft? –

Antwort

0

Ich gehe davon aus, dass Sie ein React\Socket\Server auf Port lauscht 8080 (aka php push-server.php). Das Tutorial auf der Ratschen-Website sollte Sie bis zu diesem Punkt bringen.

Ich nehme auch an, dass Sie bereits konfiguriert und geladen haben die proxy und proxy_wstunnel Apache-Module wie in der Frage erwähnt.


Unten ist die Konfiguration, die ich persönlich verwende, um eine WebSocket-Verbindung zu erreichen.

Ich benutze /ws/ anstelle der /wss2/ im Tutorial für eine besser aussehende URL erwähnt. Fühlen Sie sich frei, die Konfiguration nach Bedarf anzupassen.

Apache Config

#SSL (Secure)                                                    
<VirtualHost *:443> 
    DocumentRoot /FILE_PATH_TO_WEBROOT 
    ServerName local.sitename.com 
    ServerAlias local.sitename.com 
    <Directory /FILE_PATH_TO_WEBROOT> 
     Options FollowSymLinks 
     AllowOverride all 
     php_flag display_errors On 
     Require all granted 
    </Directory> 
    SSLCertificateFile /etc/httpd/ssl/.crt 
    SSLCertificateKeyFile /etc/httpd/ssl/.key 

    ProxyRequests Off 
    ProxyPass "/ws/" "ws://local.sitename.com:8080/" 
</VirtualHost> 

#NON-SSL (Insecure) 
<VirtualHost *:80> 
    DocumentRoot /FILE_PATH_TO_WEBROOT 
    ServerName local.sitename.com 
    ServerAlias local.sitename.com 
    <Directory /FILE_PATH_TO_WEBROOT> 
     Options FollowSymLinks 
     AllowOverride all 
     php_flag display_errors On 
     Require all granted 
    </Directory> 
    ProxyRequests Off 
    ProxyPass "/ws/" "ws://local.sitename.com:8080/" 
</VirtualHost> 

Sichere JavaScript Socket-Verbindung

var conn = new WebSocket('wss://local.sitename.com/ws/'); 

Unsichere JavaScript Buchse Anschluss

var conn = new WebSocket('ws://local.sitename.com/ws/'); 
+0

Ja! Vielen Dank! das ist so viel besser als meine eigene "Lösung". Es funktioniert perfekt –

+0

Froh, es hat auch für Sie gearbeitet! – arithran