The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mod Rewrite and proxy for Socket.io

Discussion in 'Workarounds and Optimization' started by Dennis Walsh, Jun 1, 2016.

  1. Dennis Walsh

    Dennis Walsh Registered

    Joined:
    Jun 1, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Catalina Foothills, AZ
    cPanel Access Level:
    Root Administrator
    The question is how do you configure WHM Include Editor to mod rewrite virtual hosts?

    Specifically, I'm having the following issue...

    I'm running Node and Socket.io servers behind WHM/Apache 2.4.2.

    The Node server works through a reverse proxy at port 80 by placing

    ProxyPass /backend http://localhost:8082
    ProxyPassReverse /backend http://localhost:8082

    in the Include Editor -> Post VirtualHost Include.

    Socket.io piggybacks the Node server at localhost:8082/socket.io

    I have mod_proxy and mod_proxy_wstunnel installed via Easy Apache 4.

    However, when Socket.io tries a web socket connection, the request 400s and reverts to long polling.

    I've tried placing
    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^/socket.io [NC]
    RewriteCond %{QUERY_STRING} transport=websocket [NC]
    RewriteRule /(.*) ws://localhost:8082/$1 [P,L]

    ProxyPass /socket.io http://localhost:8082/socket.io
    ProxyPassReverse /socket.io http://localhost:8082/socket.io

    into all three Include Editor locations to no avail. I've also tried Rewrite Inherit. (I've tried to just make it rewrite anything.. won't do it).

    Several others asked this question, but the response was always "put it in .htaccess." However, .htaccess does not accept ProxyPass.

    Any ideas?
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,808
    Likes Received:
    667
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello,

    You may want to try editing the template for the VirtualHost per the document located at:

    Custom Templates - EasyApache - cPanel Documentation

    This will allow you to configure the entries within the VirtualHost instead editing the global Apache configuration. Keep in mind these custom modifications changes are unsupported

    Thank you.
     
Loading...

Share This Page