Last active
September 22, 2022 11:05
-
-
Save rielcfb/d22914c83df4f26b0fe87122943e28c6 to your computer and use it in GitHub Desktop.
Revisions
-
rielcfb revised this gist
Sep 22, 2022 . No changes.There are no files selected for viewing
-
rielcfb revised this gist
Sep 22, 2022 . 1 changed file with 70 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,73 @@ # Httpd Apache/2.4.6 VHost Config Reverse Proxy Node.js App RHEL CENTOS 7 # Websocket / ws / wss / socket.io # Solved after errors: # connection_error: code 3 Bad Request # engine invalid transport upgrade # engine error handshaking to transport "websocket" # socket.io-client: websocket error # socket.io-client: failed wss connection # socket.io-client: failed connection using transport websocket / ws / wss # File: /etc/httpd/conf.d/io.example.com.conf # For port 80 / http <VirtualHost *:80> ServerName io.example.com # ----- Optional ----------------------------------------------------------- # <Proxy *> # Require all granted # </Proxy> # -------------------------------------------------------------------------- # ----- Worked Simple ------------------------------------------------------- # ProxyPreserveHost on ProxyRequests on ProxyPass /socket.io/ ws://localhost:3000/socket.io/ ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ # ---------------------------------------------------------------------------- # ----- this is general options from apache / socket.io documentation -------- # RewriteEngine on # RewriteCond ${HTTP:Upgrade} websocket [NC] # RewriteCond ${HTTP:Connection} upgrade [NC] # RewriteRule ^/?(.*) ws://localhost:1202/$1 [P,L] # ProxyTimeout 3 # ----------------------------------------------------------------------------- # ----- Redirect permanent to https ------------------------------------------- # RewriteCond %{SERVER_NAME} =io.example.com # RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] # ----------------------------------------------------------------------------- </VirtualHost> # File: /etc/httpd/conf.d/io.example.com-le-ssl.conf # For Port 443 / https <VirtualHost *:443> ServerName io.example.com:443 SSLEngine on SSLProxyEngine on # LetsEncrypt SSL SSLCertificateFile /etc/letsencrypt/live/io.example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/io.example.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateChainFile /etc/letsencrypt/live/io.example.com/chain.pem <Proxy *> Require all granted </Proxy> ProxyPreserveHost on ProxyRequest on ProxyPassMatch ^/socket.io/(.*) ws://localhost:3000/socket.io/$1 # Or # ProxyPass /socket.io/ ws://localhost:3000/socket.io/ ProxyPass / http://localhost:3000/ ProxyReverse / http://localhost:3000/ </VirtualHost> -
rielcfb created this gist
Sep 22, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ # Httpd Apache/2.4.6 VHost Config Reverse Proxy Node.js App RHEL CENTOS 7 # Websocket / ws / wss / socket.io # Solved after errors: # connection_error