• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

Apache for Newbie: Set up Apache with mod_proxy_wstunnel

December 17, 2023

Apache for Newbie: Set up Apache with mod_proxy_wstunnel

Apache is one of the most popular web servers in the world, known for its flexibility and robustness. It allows you to host websites and applications on your server, making it an essential tool for any VPS hosting provider. In this article, we will explore how to set up Apache with mod_proxy_wstunnel, a module that enables WebSocket proxying.

What is WebSocket?

WebSocket is a communication protocol that provides full-duplex communication channels over a single TCP connection. Unlike traditional HTTP, which follows a request-response model, WebSocket allows for real-time, bidirectional communication between the client and the server. This makes it ideal for applications that require instant updates, such as chat applications, real-time gaming, and collaborative tools.

Why use mod_proxy_wstunnel?

Apache’s mod_proxy_wstunnel module allows you to proxy WebSocket connections from Apache to another backend server that supports WebSocket. This means you can use Apache as a reverse proxy to handle WebSocket traffic, providing an additional layer of security and flexibility.

Setting up Apache with mod_proxy_wstunnel

Before we begin, make sure you have Apache installed on your VPS. If not, you can install it using the package manager of your operating system. Once Apache is installed, follow these steps:

Step 1: Enable mod_proxy and mod_proxy_wstunnel

First, we need to enable the necessary Apache modules. Open the Apache configuration file, which is usually located at /etc/apache2/apache2.conf or /etc/httpd/httpd.conf, depending on your operating system. Look for the following lines and uncomment them if they are commented:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so

Save the file and restart Apache for the changes to take effect.

Step 2: Configure the WebSocket proxy

Next, we need to configure the WebSocket proxy. Open the Apache configuration file again and add the following lines:

<VirtualHost *:80>
    ServerName example.com

    ProxyPass /ws ws://backend-server:8080/ws
    ProxyPassReverse /ws ws://backend-server:8080/ws
</VirtualHost>

Replace example.com with your domain name and backend-server:8080 with the address of your backend WebSocket server. Save the file and restart Apache.

Step 3: Test the WebSocket proxy

To test if the WebSocket proxy is working correctly, you can use a WebSocket client like WebSocket Echo Test. Enter the URL of your WebSocket endpoint, which should be something like ws://example.com/ws. If the connection is successful, you should see a response from the server.

Conclusion

Setting up Apache with mod_proxy_wstunnel allows you to proxy WebSocket connections and enhance the capabilities of your VPS hosting environment. By following the steps outlined in this article, you can enable real-time, bidirectional communication for your applications. Apache’s flexibility and mod_proxy_wstunnel’s WebSocket proxying capabilities make them a powerful combination for any VPS hosting provider.

Summary

In summary, Apache with mod_proxy_wstunnel is a powerful combination for hosting WebSocket applications on your VPS. By following the steps outlined in this article, you can set up a WebSocket proxy using Apache, allowing for real-time, bidirectional communication. To learn more about VPS hosting and how it can benefit your business, visit Server.HK.

Recent Posts

  • How to Set Up a Game Server on Hong Kong VPS: Low-Latency Gaming for Asia
  • How to Deploy a Node.js Application on Hong Kong VPS: Complete Guide
  • How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)
  • How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  • CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot