• 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

When it comes to web hosting, Apache is one of the most popular and widely used web servers. It is known for its flexibility, reliability, and extensive features. If you are new to Apache and want to learn how to set it up with mod_remoteip, this article is for you.

What is mod_remoteip?

Mod_remoteip is an Apache module that allows you to modify the remote IP address of a client request before it reaches your web application. This is particularly useful when your web server is behind a reverse proxy or load balancer, as the original client IP address may be hidden or replaced by the proxy’s IP address.

Why use mod_remoteip?

Using mod_remoteip is essential for accurate logging and security purposes. Without it, your web server logs will show the IP address of the proxy instead of the actual client. This can make it difficult to track and analyze user activity on your website. Additionally, some security measures, such as IP-based access control, rely on the correct client IP address.

Setting up Apache with mod_remoteip

Here are the steps to set up Apache with mod_remoteip:

Step 1: Install mod_remoteip

First, make sure you have mod_remoteip installed on your server. If you are using a VPS hosting service like Server.HK, you can easily install it through the command line. For example, on a Ubuntu server, you can run the following command:

sudo apt-get install libapache2-mod-remoteip

Step 2: Configure mod_remoteip

Once installed, you need to configure mod_remoteip. Open your Apache configuration file, which is usually located at /etc/apache2/apache2.conf or /etc/httpd/conf/httpd.conf, depending on your operating system.

Add the following lines to the configuration file:

RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1

The RemoteIPHeader directive specifies the header field that contains the client IP address. In this example, we assume that the client IP address is passed in the X-Forwarded-For header. Adjust this value according to your proxy configuration.

The RemoteIPInternalProxy directive specifies the IP address of the proxy server. In this example, we assume that the proxy server is running on the same machine as the web server. If your proxy server has a different IP address, update this value accordingly.

Step 3: Restart Apache

After making the configuration changes, restart Apache to apply the changes:

sudo service apache2 restart

Summary

Setting up Apache with mod_remoteip is crucial for accurate logging and security. By following the steps outlined in this article, you can ensure that your web server correctly identifies the client IP address, even when behind a reverse proxy or load balancer. Remember to install mod_remoteip, configure it with the appropriate header and proxy settings, and restart Apache to apply the changes.

For reliable and high-performance VPS hosting, consider Server.HK. With their Hong Kong VPS Hosting plans, you can enjoy the benefits of a virtual private server tailored to your specific needs. Visit https://server.hk to learn more about their hosting services.

Recent Posts

  • 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)
  • Managing Users and Permissions in CentOS Stream: Best Practices (CentOS Stream 9/10 – 2026)
  • How to Set Up Nginx on CentOS Stream for High-Performance Web Hosting

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