Welcome! Log In Create A New Profile

Advanced

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Francis Daly
May 22, 2017 07:10PM
On Fri, May 19, 2017 at 03:24:43AM -0400, ohmykot wrote:

Hi there,

in nginx, one request is handled in one location, and only the config in
(or inherited into) that location applies.

> On the web-site, I have a wordpress page, i.e. domain.com/secret-page/, that
> I want to restrict access to everybody but 1 specific IP address of my other
> server.

> location ~* ^/secret-page/ {
> allow 1.1.1.1;
> deny all;
> }

If the request is for /secret-page/ and is handled in that location{},
you have no explicit how-to-handle-it configuration, so the default
"serve it from the filesystem" will be used.

Assuming that you want the to be handled just like every other request,
you could add

try_files $uri $uri/ /index.php?q=$uri&$args;

in the location{}, and it will do what you asked for.

Note: this will restrict a request f or /secret-page/, but not a request
for /index.php?q=/secret-page/

The second one there is possibly functionally equivalent to the first;
if you want to restrict that as well, it would be more work in nginx.


As an aside, it may be clearer to use

location ^~ /secret-page/

instead of

location ~* ^/secret-page/

The meanings are not identical, depending on what else is in the config
file and where it is.

http://nginx.org/r/location for the details on what the various squiggles
mean.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

How to restrict acces to specific friendly URL by IP in Wordpress site?

ohmykot May 19, 2017 03:24AM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

alexsamad May 19, 2017 05:38PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

gariac May 19, 2017 06:02PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

alexsamad May 19, 2017 06:16PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Igal @ Lucee.org May 19, 2017 06:22PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Igal @ Lucee.org May 19, 2017 06:48PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

gariac May 19, 2017 07:04PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Igal @ Lucee.org May 19, 2017 07:10PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Igal @ Lucee.org May 19, 2017 05:50PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

ohmykot May 22, 2017 03:24AM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Aleksandar Lazic May 19, 2017 07:42PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Francis Daly May 22, 2017 07:10PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

gariac May 22, 2017 07:54PM

Re: How to restrict acces to specific friendly URL by IP in Wordpress site?

Francis Daly May 27, 2017 03:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 152
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready