Welcome! Log In Create A New Profile

Advanced

Re: Nginx with php configuration how to block all requests/urls other than two?

Francis Daly
January 29, 2015 01:48PM
On Thu, Jan 29, 2015 at 09:20:36AM -0500, c0nw0nk wrote:
> So i use nginx with PHP and i have the following two urls i want to allow
> access on the subdomain.
>
> The full url would be
> sub1.domain.com/index.php?option=com_hwdmediashare&task=addmedia.upload&base64encryptedstring

Usually you don't want to match $args, because the order is not fixed. But
if you are happy that it is in your case, you can just do:

server {
server_name sub1.domain.com;
location / { return 404; }
location = /index.php {
if ( $args !~ 'option=com_hwdmediashare&task=addmedia.upload' ) {
return 404;
}
# do whatever
}
}

Change "404" to whatever you want "block" to mean.

"# do whatever" will probably involve fastcgi_pass or something similar.

Note that this does not restrict access to exactly this query string;
if it matters, you can tighten things. But it is probably simpler for
your index.php to check that arguments are exactly what is expected or
else to fail.

> And
>
> sub1.domain.com/media/com_hwdmediashare/assets/swf/Swiff.Uploader.swf

location = /media/com_hwdmediashare/assets/swf/Swiff.Uploader.swf {}

> But i cant figure out in nginx how to block all other traffic/requests on
> the subdomain apart from those two urls

location /

matches any normal request that does not match any other location.

f
--
Francis Daly francis@daoine.org

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

Nginx with php configuration how to block all requests/urls other than two?

c0nw0nk January 29, 2015 09:20AM

Re: Nginx with php configuration how to block all requests/urls other than two?

itpp2012 January 29, 2015 10:09AM

Re: Nginx with php configuration how to block all requests/urls other than two?

c0nw0nk January 29, 2015 10:55AM

Re: Nginx with php configuration how to block all requests/urls other than two?

itpp2012 January 29, 2015 12:29PM

Re: Nginx with php configuration how to block all requests/urls other than two?

B.R. January 29, 2015 12:58PM

Re: Nginx with php configuration how to block all requests/urls other than two?

Francis Daly January 29, 2015 01:48PM

Re: Nginx with php configuration how to block all requests/urls other than two?

c0nw0nk January 30, 2015 02:51AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 177
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