Score:1

Nginx + jirafeau - deny acces to admin.php

cn flag

Hello i try to deny access for externe IP to my URL admin.php of my website with nginx.

I have a jirafeau server with a example.com/admin.php I try to deny acces for this page but dont work. I am new with nginx this is my conf :

location / { try_files $uri $uri/ /admin.php; deny all; allow X.X.X.X/24; }

this deny all the externe ip of my website i just need deny acces to admin.php

thx for the help!

Score:1
za flag

NGINX Short Solve:

You can use either:

  • Example 1 (should work)
    location = /admin.php {
        deny all;
        allow 10.0.0.0/8; }
  • Example 2 (I'm unsure if it's the proper one for this case)
location ~* admin.php {
        deny all;
        allow 10.0.0.0/8; } 
  • Example 3 Combined with Basic-Auth
    location = /admin.php {
        deny all;
        allow 10.0.0.0/8; }
        auth_basic              "restricted area";
        auth_basic_user_file    /etc/nginx/htpw/.htpasswd;

  • Example 4 Basic-Auth only.
    location = /admin.php {
        auth_basic              "restricted area";
        auth_basic_user_file    /etc/nginx/htpw/.htpasswd;

Remind that your Browser-Cache can tricky yourself if it's not working directly (if you didn't forgot to reload nginx, of course.)

Reference:

  1. Stackoverflow
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.