Last active
September 22, 2022 11:05
-
-
Save rielcfb/d22914c83df4f26b0fe87122943e28c6 to your computer and use it in GitHub Desktop.
Httpd Apache/2.4.6 VHost Config Reverse Proxy Node.js App RHEL CENTOS 7
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 characters
| # 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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment