FG
📡 Networking

Apache 2.4 ProxyPass Configuration

Freshover 11 years ago
Mar 14, 20260 views
Confidence Score80%
80%

Problem

With 0.9 I was able to proxy our websockets through Apache 2.4 using the following config: [code block] I'm attempting to migrate to 1.0.6 now and I immediately noticed that the socket endpoint changed, but updating the ProxyPass config like so does not seem to do the trick. [code block] Chrome reports over and over again that it receives a 400 error when trying to open the websocket. There's no output in the console on the server to indicate that any connection attempt was received (DEBUG=socket.io). Is there some other configuration factor that I need for this to work?

Error Output

error when trying to open the websocket.  There's no output in the console on the server to indicate that any connection attempt was received (DEBUG=socket.io).

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
77% confidence100% success rate5 verificationsLast verified Mar 14, 2026

Solution: Apache 2.4 ProxyPass Configuration

Low Risk

Although not ideal, I managed to make it work without modifying socket.io by using a combination of Apache's mod_rewrite to check the transport query string parameter, and if it's set to "polling" proxy to the http url, otherwise proxy to the ws: url. Rewriting to the ws: protocol with a RewriteRule did not seem to work correctly here, so therefore ProxyPass was still necessary. Here's the code,

77

Trust Score

5 verifications

100% success
  1. 1

    Although not ideal, I managed to make it work without modifying socket.io by usi

    Although not ideal, I managed to make it work without modifying socket.io by using a combination of Apache's mod_rewrite to check the transport query string parameter, and if it's set to "polling" proxy to the http url, otherwise proxy to the ws: url. Rewriting to the ws: protocol with a RewriteRule did not seem to work correctly here, so therefore ProxyPass was still necessary.

    text
    RewriteEngine on
    
    RewriteCond %{QUERY_STRING} transport=polling
    RewriteRule /(.*)$ http://localhost:3000/$1 [P]
    
    ProxyRequests off
    ProxyPass /socket.io/ ws://localhost:3000/socket.io/
    ProxyPassReverse /socket.io/ ws://localhost:3000/socket.io/
  2. 2

    Here's the code, for a socket.io server on port 3000:

    Here's the code, for a socket.io server on port 3000:

Validation

Resolved in socketio/socket.io GitHub issue #1696. Community reactions: 11 upvotes.

Verification Summary

Worked: 5
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

socket.iowebsocketrealtime