Welcome! Log In Create A New Profile

Advanced

Re: Setting Allow / Deny Rules + Keep processing other location rules?

Maxim Dounin
July 05, 2014 04:46PM
Hello!

On Sat, Jul 05, 2014 at 12:29:18PM -0400, Mayhem30 wrote:

> I'm having a heck of a time setting allow / deny rules for certain
> directories and files + getting Nginx to keep handling other location
> rules.
>
> For example, I want to only allow my IP address access to the WordPress
> login page:
>
> location ~* wp-login.php {
> allow 22.131.12.14;
> deny all;
> }
>
> # Pass off php requests to Apache
> location ~* \.php$ {
> include /usr/local/etc/nginx/proxypass.conf;
> proxy_pass http://127.0.0.1:80;
> }
>
> When I visit the WordPress login page, all I see is the raw PHP code.
>
> How can I set up the first location block to allow me to add allow / deny
> rules, charset, headers, etc + have PHP files still processed by the second
> location block?

To process a request nginx will select only one location block.
Therefore, the only way is to specify full configuration in a
single location block.

E.g., in this particular case you have to write something like
this:

location ~* wp-login.php {
allow 22.131.12.14;
deny all;
include /usr/local/etc/nginx/proxypass.conf;
proxy_pass http://127.0.0.1:80;
}

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Setting Allow / Deny Rules + Keep processing other location rules?

Mayhem30 July 05, 2014 12:29PM

Re: Setting Allow / Deny Rules + Keep processing other location rules?

Maxim Dounin July 05, 2014 04:46PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 161
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready