• 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: Allow IP addresses

December 17, 2023

Apache for Newbie: Allow IP Addresses

Apache is one of the most popular web servers in the world, and for good reason. It’s reliable, secure, and highly customizable. However, for those new to Apache, configuring it to allow specific IP addresses can be a daunting task. In this article, we’ll walk you through the process step-by-step, with relevant examples and code samples to help you along the way.

Understanding Apache Configuration

Before we dive into allowing IP addresses, it’s important to understand how Apache configuration works. Apache uses a file called httpd.conf to store its configuration settings. This file is typically located in the /etc/httpd/ or /etc/apache2/ directory, depending on your operating system.

The httpd.conf file contains various directives that control how Apache behaves. These directives are organized into sections, such as <Directory>, <Files>, and <Location>, which apply to different parts of the file system or URL space.

Allowing IP Addresses in Apache

To allow specific IP addresses in Apache, you’ll need to use the Require directive within a <Directory>, <Files>, or <Location> section. The Require directive is used to specify which users or hosts are allowed to access a particular resource.

For example, to allow access to a directory only from a specific IP address, you would use the following configuration:

<Directory "/var/www/html/secure">
    Require ip 192.168.1.100
</Directory>

This configuration would allow only the IP address 192.168.1.100 to access the /var/www/html/secure directory.

Allowing Multiple IP Addresses

If you want to allow multiple IP addresses, you can simply list them all on the same line, separated by spaces:

<Directory "/var/www/html/secure">
    Require ip 192.168.1.100 192.168.1.101 192.168.1.102
</Directory>

Alternatively, you can use the Require directive multiple times:

<Directory "/var/www/html/secure">
    Require ip 192.168.1.100
    Require ip 192.168.1.101
    Require ip 192.168.1.102
</Directory>

Allowing IP Ranges

If you want to allow an entire range of IP addresses, you can use CIDR notation:

<Directory "/var/www/html/secure">
    Require ip 192.168.1.0/24
</Directory>

This configuration would allow any IP address in the range 192.168.1.0 to 192.168.1.255 to access the /var/www/html/secure directory.

Denying IP Addresses

In addition to allowing IP addresses, you can also deny them using the Require directive. For example, to deny access to a directory from a specific IP address, you would use the following configuration:

<Directory "/var/www/html/secure">
    Require all granted
    Require not ip 192.168.1.100
</Directory>

This configuration would allow access to the /var/www/html/secure directory from all IP addresses except 192.168.1.100.

Conclusion

Configuring Apache to allow or deny specific IP addresses is a powerful way to control access to your web server. By using the Require directive within the appropriate sections of your httpd.conf file, you can easily specify which users or hosts are allowed to access your resources.

Whether you’re running a Hong Kong VPS, a shared hosting account, or a dedicated server, understanding how to configure Apache is an essential skill for any webmaster. With the examples and code samples provided in this article, you should now have a solid foundation for allowing IP addresses in Apache.

Remember, if you’re looking for reliable and secure Hong Kong VPS Hosting, look no further than Server.HK. With our top-notch infrastructure and expert support, you can rest assured that your website is in good hands.

Recent Posts

  • How to Run a SaaS Product on Hong Kong VPS: Architecture and Deployment Guide 2026
  • Hong Kong VPS Uptime and SLA: What 99.9% Uptime Really Means for Your Business (2026)
  • Cryptocurrency and USDT Payment for VPS Hosting: Why It Matters for Global Businesses (2026)
  • How to Speed Up Your Website for China: A Technical Optimization Guide 2026
  • Hong Kong VPS Windows Server: How to Set Up and Use a Windows VPS in Asia (2026)

Recent Comments

  1. Hong Kong VPS Uptime and SLA: What 99.9% Uptime Really Means for Your Business (2026) - Server.HK on How to Monitor Your Hong Kong VPS: Uptime, Performance, and Alert Setup Guide (2026)
  2. Best Hong Kong VPS Providers in 2026: Compared by Speed, Routing, and Value - Server.HK on How to Migrate Your Website to a Hong Kong VPS: Zero-Downtime Transfer Guide (2026)
  3. vibramycin injection on How to Choose the Right Hong Kong VPS Plan: A Buyer’s Guide for 2026
  4. allopurinol for gout on CN2 GIA vs BGP vs CN2 GT: What’s the Real Difference for China Connectivity?
  5. antibiotics online purchase on How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)

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