skip to Main Content

hello i have this config in my apache

<Directory "/phpmyadmin/">
    Require all denied
</Directory>

how i can make this code valid for nginx config

this is what i tried

location /phpmyadmin {

           Deny All;

        }

but when i close my nginx server i got this

nginx: [emerg] unknown directive "Deny" in C:nginx/conf/nginx.conf:49

someone know how to fix this ??

2

Answers


  1. Apache and nginx share little to none config params. For nginx deny, you go with

    location /phpmyadmin {
        return 403;
    }
    
    Login or Signup to reply.
  2. To restrict a directory or multiple directories in nginx conf file, you can do like this:

    ...
    location ~ /(dir1|dir2|dir3) {
       deny all;
       return 404;
    }
    ...
    

    in your case, you can try like this:

    ...
    location /phpmyadmin {
       deny all;
       return 404;
    }
    ...
    

    If you want, you can redirect to a specific route too based on the status code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search