how to deny directory by ip address in nginx

Discussion in 'Server Operation' started by scars230, Sep 2, 2010.

  1. scars230

    scars230 New Member

    Hi
    Suppose i got /var/www/website/secretfiles

    I want secretfiles to be accessed by only a few specific static ip addresses

    How do i achieve this ?
    This was possible in Apache2 using .htaccess files.
    But i really dont know how to get it going with nginx.

    Please advice.

    Thank You
     
  2. Mark_NL

    Mark_NL New Member

    Code:
    location <dir> {
      allow 1.2.3.4/32; # To give one ip access
      allow 192.168.1.0/24; # To give a whole network access
      deny all;
    }
     
  3. scars230

    scars230 New Member

    i put these in nginx.conf ?
    using debian lenny
     
  4. Mark_NL

    Mark_NL New Member

    /etc/nginx/sites-enabled/default ?
     
  5. scars230

    scars230 New Member

    Okay thanks :)
     
  6. scars230

    scars230 New Member

Share This Page