Proxy websocket wss:// to ws:// apache

后端 未结 6 739
自闭症患者
自闭症患者 2021-02-02 02:15

i searched alot but i couldnt connect my websocket to wss:// , i found that there is a way to proxy wss://domain.com:9090 and apache apply the proxy on it and redirect request

6条回答
  •  有刺的猬
    2021-02-02 02:39

    the problem I was trying to solve was similar to this one. I have a reverse proxy running under Apache 2.4 on CentOs 7 which has to work with both https and wss requests.

    Behind the reverse proxy I have my app server running on an internal network. the virtual host configuration in the /etc/httpd/httpd.conf config file is as follows:

    
       ServerName example.com
       RewriteCond %(HTTP:Upgrade) websocket [NC]   # Required to handle the websocket connection
       RewriteCond %(HTTP:Connection) upgrade [NC]
       RewriteRule /(.*) ws://192.160.0.1/$1 [P,L]
    
      SSLEngine on # SSL Certificates handling
      SSLCertificateFile ssl/cert.pem # Public Certificate
      SSLCertificateKeyFile ssl/key.pem # Private certificate
      SSLCertificateChainFile ssl/ca.pem # CA or chain certificate
    
     ProxyPreserveHost On
     ProxyPass /websocket ws://192.168.0.1 # First you need to write the specific rules
     ProxyPassReverse /websocket ws://102.168.0.1
     ProxyPass / http://192.168.0.1 # Then the generic rules for the proxy.
     ProxyPassReverse / http://192.168.0.1
     
    

    In your case, you will have to replace the ServerName, the SSL certificates location, and the destination of the proxy.

提交回复
热议问题