• 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_remoteip

December 17, 2023

Apache for Newbie: Set up Apache with mod_remoteip

Apache is one of the most popular web servers in the world, known for its flexibility, reliability, and security. If you are new to Apache and want to learn how to set it up with mod_remoteip, this article will guide you through the process step by step.

What is mod_remoteip?

Mod_remoteip is an Apache module that allows you to restore the original client IP address when using a reverse proxy. When a request passes through a reverse proxy, the client IP address is replaced with the IP address of the proxy server. Mod_remoteip helps Apache retrieve the correct client IP address, which is crucial for various applications like logging, access control, and security.

Step 1: Install Apache

The first step is to install Apache on your server. If you are using a Linux distribution like Ubuntu or CentOS, you can use the package manager to install Apache. For example, on Ubuntu, you can run the following command:

sudo apt-get install apache2

Once the installation is complete, you can start Apache using the following command:

sudo systemctl start apache2

Step 2: Enable mod_remoteip

After installing Apache, you need to enable the mod_remoteip module. On Ubuntu, you can enable it by running the following command:

sudo a2enmod remoteip

Once the module is enabled, you need to configure it to use the correct IP address. Open the Apache configuration file using a text editor:

sudo nano /etc/apache2/apache2.conf

Scroll down to the end of the file and add the following lines:

RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1

The “RemoteIPHeader” directive specifies the header used by the reverse proxy to pass the client IP address. In this example, we are using the “X-Forwarded-For” header, which is commonly used by many reverse proxies.

The “RemoteIPInternalProxy” directive specifies the IP address of the reverse proxy server. In this example, we are using the loopback address “127.0.0.1” as an example. Replace it with the IP address of your reverse proxy server.

Save the file and exit the text editor.

Step 3: Restart Apache

After making the configuration changes, you need to restart Apache for the changes to take effect. Run the following command:

sudo systemctl restart apache2

Step 4: Verify the Configuration

To verify that mod_remoteip is working correctly, you can check the Apache access logs. The access logs should now show the original client IP address instead of the proxy server’s IP address.

Open the Apache access log file using a text editor:

sudo nano /var/log/apache2/access.log

Look for the IP addresses in the log file. You should see the original client IP address instead of the proxy server’s IP address.

Conclusion

Setting up Apache with mod_remoteip is essential when using a reverse proxy. It allows Apache to retrieve the correct client IP address, which is crucial for various applications. By following the steps outlined in this article, you can easily set up Apache with mod_remoteip and ensure that your server logs and security measures are accurate and effective.

For more information about Hong Kong VPS hosting solutions, visit Server.HK.

Recent Posts

  • Hong Kong VPS vs Japan VPS: Head-to-Head for Asia-Pacific Deployments in 2026
  • Hong Kong VPS vs Singapore VPS: Which Is Better for Your Asia Business in 2026?
  • How to Migrate from CentOS 8 to AlmaLinux or Rocky Linux Safely
  • CentOS Server Performance Tuning: Optimization Techniques for 2026
  • How to Configure SELinux in CentOS Without Breaking Your System (CentOS Stream 9/10 – 2026)

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