1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Deny from all

Discussion in 'Nginx' started by Sebastian L., Dec 28, 2017.

  1. #1
    Hello,
    If it is possible to add some on default.conf that i can deny all from my page and only allow some IP?

    Here is my default.conf but I dont know how I need to do...

    server {
    set $rootpath "/var/www/ipmp";
    root $rootpath;
    listen 80;
    
    if ($request_uri ~ (/).*) {
    rewrite ^ https://$host$request_uri? permanent;
    }
    if ($request_uri ~ (/mobile/).+) {
    rewrite ^ https://$host$request_uri? permanent;
    }
    if ($request_uri ~ (/interactive/).*) {
    rewrite ^ https://$host$request_uri? permanent;
    }
    
    include /etc/nginx/part.d/*.part;
    }
    server {
    set $rootpath "/var/www/ipmp";
    root $rootpath;
    listen 443 ssl;
    keepalive_timeout 70;
    
    server_name $host;
    ssl_certificate /ha_shared/ipmp/config/certificates/cert.csr;
    ssl_certificate_key /ha_shared/ipmp/config/certificates/cert.key;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 10m;
    
    include /etc/nginx/part.d/*.part;
    include /etc/nginx/part.d/onlyssl/*.part;
    }
    Code (markup):
    Where I need add that deny all? That is my root path: /var/www/ipmp . Hope some can help.
     
    Sebastian L., Dec 28, 2017 IP
  2. hostechsupport

    hostechsupport Well-Known Member

    Messages:
    413
    Likes Received:
    23
    Best Answers:
    7
    Trophy Points:
    138
    #2
    This can be improved by using the directive designed for that task.

    ErrorDocument 403 /specific_page.html
    Order Allow, Deny
    Allow from 111.222.333.444

    Where 111.222.333.444 is your static IP address.

    While using the "Order Allow, Deny" directive, the request must match either Allow or Deny, if none is met, the request is denied.
     
    hostechsupport, May 14, 2018 IP
  3. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #3
    Hi Sebastian,

    You can create a new Nginx location block with the following content:

    location / {
    
      allow  1.2.3.4;
      deny  all;
    }
    Code (markup):
    Replace 1.2.3.4 with your actual IP address, and restart Nginx for the changes to take effect.
     
    RoseHosting, May 22, 2018 IP