Skip to content
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Roadmap
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Contact us: +34 944 58 06 58
  • Plesk Partner Program
  • Roadmap
  • Plesk Lifecycle Policy
  • Blog
  • Contact us
  • Plesk 360
  • Solutions
    By Role
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    • Developers
    • Content Managers
    • Digital Agencies
    • IT Admins
    • Web Hosters
    • Hyperscalers
    By Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    • Web Admin Edition
    • Web Pro Edition
    • Web Host Edition
    • Business & Collaboration
    • Plesk WP Edition
    By Cloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    • Amazon Web Services
    • Microsoft Azure
    • Alibaba Cloud
    • GCP Marketplace
    • Vultr
    • DigitalOcean
    • Linode
    • UpCloud
    Partner Program
    Exclusive discounts, benefits and exposure to take your business to the next level
    Become a partner
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    Explore Features
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    • Roadmap
    • Everyone
    • Admins & Web Hosters
    • Developers
    • Designers & Agencies
    • Plesk Features
    • Roadmap
    Key Topics
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    • SocialBee
    • WP Toolkit
    • Sitejet Builder
    • SEO Toolkit
    • Joomla! Toolkit
    • Plesk Premium Email
    • Plesk Email Security
    Feature Packs
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    • Business & Collaboration
    • WP Pack
    • Hosting Pack
    • Power Pack
    • Language Pack
    Featured Extension
    SocialBee
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder for Plesk
      • SEO Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • Extension
  • Pricing
  • Extensions
  • Help Center
  • More
    • Careers
    • Events
    • Plesk University
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Roadmap
    • Plesk Lifecycle Policy
    • Contact Us
  • FREE TRIAL
  • Solutions
    • By Role
      • Developers
      • Content Managers
      • Digital Agencies
      • IT Admins
      • Web Hosters
      • Hyperscalers
    • By Edition
      • Web Admin Edition
      • Web Pro Edition
      • Web Host Edition
      • Business & Collaboration
      • WP Edition
    • By Cloud
      • Amazon Web Services
      • Microsoft Azure
      • Alibaba Cloud
      • GCP Marketplace
      • Vultr
      • DigitalOcean
      • Linode
      • UpCloud
    • Partner Program
      • Partner Program
  • Product
    • Explore Features
      • Everyone
      • Admins & Web Hosters
      • Developers
      • Designers & Agencies
      • Plesk Features
    • Key Topics
      • SocialBee
      • WP Toolkit
      • Sitejet Builder
      • SEO Toolkit
      • Joomla! Toolkit
      • Plesk Premium Email
      • Plesk Email Security
    • Feature Packs
      • Business & Collaboration
      • WP Pack
      • Hosting Pack
      • Power Pack
      • Language Pack
    • Featured Extension
      • SocialBee
  • Pricing
  • Extensions
  • Help center
  • More
    • Careers
    • Events
    • Plesk University
    • Blog
    • Plesk Partner Program
    • Roadmap
    • Plesk Lifecycle Policy
    • Contact Us
  • FREE TRIAL

Knowledge Base

How to allow access to a website directory from specific IP address in Plesk?

 
apachecentosdebiandomainsfastcgi

Question

How to allow access to a website directory from specific IP address in Plesk?

Answer

Using Plesk GUI

  • If Reverse Proxy Server (nginx) is enabled in Tools & Settings > Services Management and PHP handled by Apache in Domains > example.com > PHP Settings:

    1. Log into Plesk.

    2. Open Domains > example.com > Apache & nginx Settings.

    3. Disable Serve static files directly by nginx.
    4. Add the following in Additional directives for HTTP/S  section, where 203.0.113.2 is the IP address from which access to a directory should be allowed.:

      <Location "/exampledirectory">
      Order Deny,Allow
      Deny from all
      Allow from 203.0.113.2
      </Location>

  • If Reverse Proxy Server (nginx) is enabled in Tools & Settings > Services Management and PHP handled by nginx in Domains > example.com > PHP Settings, where 203.0.113.2 - IP address from which access to a directory should be allowed:

    1. Log into Plesk.

    2. Open Domains > example.com > Apache & nginx Settings.

    3. Add the following in Additional nginx directives section:

      location / {
      try_files $uri $uri/ /index.php;
      }
      location ^~ /exampledirectory {
      allow 203.0.113.2;
      deny all; location /exampledirectory/ {
      index index.php; }
      location ~ ^/~(.+?)(/.?.php)(/.)?$ { alias /var/www/vhosts/example.com/web_users/$1/$2;
      fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_pass "unix:///var/www/vhosts/system/example.com/php-fpm.sock";
      include /etc/nginx/fastcgi.conf;
      }
      location ~ .php(/.*)?$ {
      fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_pass "unix:///var/www/vhosts/system/example.com/php-fpm.sock";
      include /etc/nginx/fastcgi.conf;
      }
      }

  • If Reverse Proxy Server (nginx) is disabled in Tools & Settings > Services Management

    1. Log into Plesk.

    2. Open Domains > example.com > Apache & nginx Settings, where 203.0.113.2 - IP address from which access to a directory should be allowed.

    3. Add the following to Additional Apache directives section:

      <Location "/exampledirectory">
      Order Deny,Allow
      Deny from all
      Allow from 203.0.113.2
      </Location>

Directly on the server

  1. Connect to the server via SSH.

  2. Find what version of Apache Web Server is installed on the server:

    • for CentOS/RHEL-based distributions:

      # httpd -v | grep version
      Server version: Apache/2.2.15 (Unix)

    • for Debian/Ubuntu-based distributions:

      # apache2 -v | grep version
      Server version: Apache/2.4.18 (Ubuntu)

  3. Check that authz_host_module is installed and enabled:

    • for CentOS/RHEL-based distributions:

      # httpd -M | grep 'authz_host_module'
      authz_host_module (shared)

    • for Debian/Ubuntu-based distributions:

      # apache2ctl -M | grep 'authz_host'
      authz_host_module (shared)

  4. Create .htaccess file in the directory where access should be restricted, for example /var/www/vhosts/example.com/httpdocs/exampledirectory/.htaccess using a text editor and add the following content:

    • For Apache Web Server version lower than 2.4:

      Order Deny,Allow
      Deny from all
      Allow from 203.0.113.2
      Allow from 203.0.113.3

    • For Apache Web Server 2.4 and greater:

      <IfModule mod_authz_host.c>
      <RequireAny>
      Require ip 203.0.113.2
      Require ip 203.0.113.3
      </RequireAny>
      </IfModule>

    Note: make sure to add the correct IP address to the allow list. The actual IP address used to access the site from, can be seen at https://ifconfig.co/

Tweet
Share
Share
Email
0 Shares
Read the full article
Related Posts

Your Complete .htaccess Guide: Including .htaccess Basics and More

Read More »

NGINX vs Apache – Which Is the Best Web Server in 2024?

Read More »

PHP-FPM: The Future of PHP Handling

Read More »
Knowledge Base

How to install the php-mcrypt module on a Plesk server

Read More »

Website or webmail shows 500 internal server error on Plesk: mod_fcgid: read data timeout

Read More »

Perl or cgi script cannot be executed: 500 Internal Server Error

Read More »

How to configure Apache to process PHP code inside an .html file on a Plesk server

Read More »

Hosting Wiki

  • Server Redundancy
  • CGI
  • htaccess
  • Bare Metal Server
  • PhpMyAdmin
  • phpPgAdmin
  • Oracle VM Server
  • Server Virtualization Software
  • Windows Server
  • Linux
  • JavaScript
  • PHP
  • HTTP/3
  • HTTP/2
  • Domain
  • Plesk
  • Lighttpd
  • Apache Tomcat
  • NGINX
  • Apache
  • Web Server
  • DNS Server
  • IPv6
  • IPv4
  • SIP
  • SSH
  • UDP/IP
  • TCP/IP
  • HTTP

Industry
Partners

industry-partner_ALIBABA
industry-partner_GOOGLEPARTNER
industry-partner_MICROSOFT
industry-partner_REDHAT-r2
industry-partner_ALIBABA
industry-partner_AUTOMATTIC
industry-partner_AWS
industry-partner_DIGITALOCEAN
industry-partner_SCALEWAY
Follow us:
Facebook Twitter Linkedin Youtube Github

COMPANY

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY

Blog
Forums 
Plesk University

First defaul

Company

About Plesk
Our Brand
Legal
Careers
Impressum

PRODUCT

Pricing 
Extensions
What’s new

KNOWLEDGE BASE​

Documentation
Help Center
Migrate to Plesk
Contact Us
Hosting Wiki
Preview releases

PROGRAMS​

Contributor Program NEW
Partner Program
Affiliate ProgramNEW

COMMUNITY​

Blog
Forums
Plesk University

Follow us:
Facebook Twitter Linkedin Youtube Github

© 2025 WebPros International GmbH. All rights reserved. Plesk and the Plesk logo are trademarks of WebPros International GmbH.

Managed with love with Plesk WP Toolkit