Score:0

Apache / Websockets: Direct Sockets to Different (Or To Both) Ports Based On Path - ProxyPass

gb flag

I am running a website on Apache. I have two apps that use web sockets, one is based on Node, which uses port 3000 and the other is based on Phoenix, which uses port 4000. Both apps also use a reverse proxy. For example, I have something like this:

  <Location /node/>
    ProxyPass http://127.0.0.1:3000/
    ProxyPassReverse http://127.0.0.1:3000/
  </Location>

  <Location /phoenix/>
    ProxyPass http://127.0.0.1:4000/
    ProxyPassReverse http://127.0.0.1:4000/
  </Location>

However, I am having problems getting the web sockets to work. I have something like this this set up for the Node app (outside the <Location> context):

  RewriteCond %{QUERY_STRING} transport=polling       [NC]
  RewriteRule /(.*)           http://127.0.0.1:3000/$1 [P]
  RewriteCond %{HTTP:Upgrade} websocket               [NC]
  RewriteRule /(.*)           ws://127.0.0.1:3000/$1  [P]

I developed my Node app a few years ago and everything worked perfectly. However, I am currently developing the Phoenix app, and I don't know how to handle directing the sockets. Eventually, I plan on phasing out the Node app completely, but I need to keep it running for our users until the new app is developed. However, I still need the new app running at the same time on the website so I can develop it. It would be nice to get sockets working on both apps at the same time.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.