How to set up Laravel Reverb in a production with Apache server

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

How to Set Up Laravel Reverb in Production with Apache: Solving WebSocket Proxy Issues

Setting up modern, real-time applications like those built with Laravel and Laravel Reverb behind a production web server like Apache can introduce subtle yet frustrating configuration headaches. You’ve successfully established the connection locally, but when deploying to a production environment using a reverse proxy, the WebSockets simply fail to establish communication. This is a very common stumbling block when bridging standard HTTP serving (Apache) with persistent protocols (WebSockets).

As a senior developer, I've seen this exact scenario repeatedly. The core issue usually isn't with Laravel or Reverb itself, but rather how the reverse proxy configuration (ProxyPass, ProxyPassReverse) interacts with the specific protocol handshake required by WebSockets and how the server handles subsequent HTTP method routing.

Let’s dive into why you are encountering the "POST method is not supported" error and how to correctly configure Apache to serve your Laravel Reverb application seamlessly.


The Anatomy of the Problem: Proxying WebSockets

You have correctly identified the core conflict: local development works because localhost directly handles the connection, but production fails when Apache sits in the middle.

Your setup involves:

  1. Client $\rightarrow$ Apache (Port 443/HTTPS)
  2. Apache $\rightarrow$ Reverb Server (Port 8080/WS)

The error message you received (The POST method is not supported...) indicates that while the initial WebSocket handshake might be succeeding (which is why you see connection established events), the subsequent attempt by the server to process an event subscription request via a standard HTTP route (like the one defined in Factory.php) is being rejected by Apache or the proxy layer because it doesn't recognize the necessary context for that specific routing path under the proxied URL structure.

This often happens when the proxy configuration doesn't correctly handle the protocol upgrade required for WebSockets, or if the server (Apache) interferes with the internal connection established by the WebSocket stream.

Correct Configuration for Laravel Reverb and Apache

The key to solving this lies in ensuring that Apache properly forwards the request headers and handles the protocol negotiation correctly for both standard HTTP traffic and the WebSocket stream. Since you are dealing with WebSockets, we need to ensure the proxy is agnostic about the underlying transport layer while still allowing the service access.

Here is a refined approach focusing on robust reverse proxy setup:

1. Environment Variables Review

Ensure your .env configuration accurately reflects the public-facing URL and port for external access:

REVERB_HOST="www.mydomain.com"
REVERB_PORT=443 # Note: WebSockets typically run over the same port as HTTPS (443) or a separate WebSocket port if desired, but mapping to 443 is common for SSL termination.
REVERB_SCHEME=https

2. Refining the Virtual Host Configuration

Instead of relying solely on ProxyPass for complex WebSocket setups, ensure your configuration handles the path correctly and explicitly allows the necessary headers. While your original setup was close, we need to focus on clean routing:

<VirtualHost *:443>
    ServerName www.mydomain.com
    SSLEngine on
    
    # Proxy the application traffic. Use a specific path if possible.
    ProxyPass /app/ ws://0.0.0.0:8080/app
    ProxyPassReverse /app ws://0.0.0.0:8080/app

    # Essential for allowing WebSocket upgrades
    SSLRedirect on
</VirtualHost>

Developer Insight: When using ProxyPass with protocols like ws://, the proxy acts as a bridge. If you encounter method errors, it often means that Apache is intercepting the request before the internal Laravel routing stack can fully process the necessary WebSocket context. Ensure your server configuration prioritizes the forwarding of raw connection streams over strict HTTP method validation for those specific paths.

Conclusion: Trusting the Laravel Ecosystem

The fact that your initial connection handshake succeeded confirms that the underlying network path is open, and the issue resides entirely within the interaction between the Apache proxy layer and the application's internal routing logic for event subscriptions.

When deploying complex frameworks like Laravel applications, always remember to consult official documentation regarding reverse proxy best practices. For deep dives into framework architecture and robust deployment strategies, consulting resources like those found at Laravel Company is invaluable. By carefully configuring your SSL termination and WebSocket proxy rules, you can ensure that your powerful Laravel Reverb application functions flawlessly in production, delivering real-time experiences without friction.