System Status
Buy Now
  • Email & Apps
  • Office 365
Login
  • MyRackspace Portal
  • Cloud Control Panel
  • Rackspace Webmail Login
  • Cloud Office Control Panel
  • Support Home
  • How-To
  • Developer Documentation
  •  Blogs 
    • Expert Insights Tech Blog
    • Rackspace Blog
    • Solve: Thought Leadership

Support Network

End-to-End Multicloud Solutions.   Solving Together.â„¢   Learn more at Rackspace.com

How–To Home

Cloud Servers

  • Introduction
  • FAQ
  • All Articles

Nginx Whitelist certain IP’s

Last updated on:  2021-09-25

Authored by:  Rocio Rodriguez


Note: This article assumes that you have installed Nginx on your server.

Prerequisites

  • An Nginx server.
  • Access to a Linux privileged user such as root.

Procedure

  1. Login into your server via SSH and switch to root user.

    su
    
  2. Go to your Nginx site configuration.

    cd /etc/nginx/sites-available
    
  3. Open the configuration file where your site is located.

    Note: This and the following steps may change depending on your configuration. We will assume that you are using the default one.

    nano default
    

    or

    vim default
    
  4. Add the following directives with your desire IP inside the server section.

    server {
        allow 192.168.0.0; # here goes the IP you want to allow
        deny all;
        # ...
    }
    

    You can also write the directives inside the http section to apply it to multiple virtual hosts.

    http {
        allow 192.168.0.0; # here goes the IP you want to allow
        deny all;
    
        server {
            server_name page1.rackspace.com;
            # ...
        }
    
        server {
            server_name page2.rackspace.com;
            # ...
        }
    }
    
  5. Save and close your file. To save: Ctrl + O Enter

    To exit: Ctrl + X

  6. Restart Nginx

    Note: This step can change depending on your OS.

    systemctl restart nginx
    

Share this information:

©2020 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

See license specifics and DISCLAIMER

About Rackspace
  • About
  • Customer Stories
  • Events
  • Programs
Blogs
  • The Rackspace Blog
  • Expert Insights Tech Blog
  • Solve: Thought Leadership
  • News
  • Contact Information
  • Legal
  • Careers
Site Information
  • Style Guide for Technical Content
  • Trademarks
  • Privacy Statement
  • Website Terms
Support Network
  • Support Network Home
  • Rackspace How-To
  • API Documentation
  • Developer Center
  • ©2020 Rackspace US, Inc.