Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on LowEndTalk.com
Tired from nginx non-sense
New on LowEndTalk? Please Register and read our Community Rules.

Tired from nginx non-sense

LTnigerLTniger Member
edited February 15 in Help

So, I have migrated from Apache to wonderful world of Nginx. And of course it was a darn mistake... Simple problem on my hands provided on the snippet bellow:

server {
    listen              443 ssl http2;
    server_name         domain.tld;
    set                 $base /var/www/domain.tld;
    root                $base/;

        # restrict methods
    if ($request_method !~ ^(GET|POST|HEAD|OPTIONS|TRACE)$) {
        return '405';
    }

    # index.php
    index      index.php;

   # index.php fallback
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # handle .php
    location ~ \.php$ {
        include nginxconfig.io/php_fastcgi.conf;
    }

        location ~ /superfolder {
           allow  127.0.0.1;
           deny all;
           return 404;
        }

        location ~ /\.ht {
                deny  all;
        }
}

Now that "superfolder" access restriction part is not working. I mean, yes, I can't access domain.tld/superfolder but I can access domain.tld/superfolder/superscript.php

It drives me nuts! I tried these variations:

location ^~ /superfolder {
           allow  127.0.0.1;
           deny all;
           return 404;
}

And:

location ~ /superfolder/.*\.(php)$ {
           allow  127.0.0.1;
           deny all;
           return 404;
}

Anyone who has more experience with Nginx - help, I'am stuck.

#!/Bashblog.net | Free Wordpress Hosting | If you can't idle, what's the point?

Comments

Sign In or Register to comment.