Welcome! Log In Create A New Profile

Advanced

Re[4]: Regular Expression global redirect

Max
February 27, 2012 10:48PM
27 февраля 2012, 14:13 от António P. P. Almeida <appa@perusio.net>:
> On 27 Fev 2012 07h33 CET, nginxyz@mail.ru wrote:
> > 27 февраля 2012, 04:41 от António P. P. Almeida <appa at perusio.net>:
> > > server {
> > > listen 80;
> > > server_name ~^www\.(?P<domain>.*)$;
> > > return 301 $scheme://$domain$request_uri;
> > > }
> > >
> > > server {
> > > listen 80;
> > > server_name ~^(?P<domain_name>[^\.]*)\.(?P<tld>[^\.]*)$;
> > > location / {
> > > proxy_pass http://$domain_name.$tld;
> > > }
> > > }
> > >
> > > This should work [1].
> >
> > Your solution, while syntactically correct, is wrong by design.
> > What you created there is an open anonymizing proxy that will pass
> > any request from anyone to any host:port combination that contains
> > only the domain name and the TLD, if a functional resolver has been
> > set up using the resolver directive. Take a guess what this would
> > do:
>
> This deals with illegal Host headers:
>
> server {
> listen 80 default_server;
> server_name _;
> server_name_in_redirect off;
> return 444;
> }

If by deals you mean gives a card to every player who wants one,
then you are correct. :-P But it does nothing to close that open
anonymizing proxy you created with the previous server block,
anyone can still use your frontend server as an open anonymizing
proxy to access any domain.tld:port they want, including fbi.gov:22.

Besides, server_name_in_redirect is off by default. Moreover,
it's completely useless in that server block because you're just
dropping the connection anyway. This would have been just
as useful:

proxy_set_header Warning "CPU cycle wasting in progress...";

As for illegal Host headers, nginx takes care of those on its
own and returns error code 400 without such blocks. The
purpose of such blocks is to catch everything else that is not
matched by defined server names. In your case, the other two
server blocks already match any requests that have the Host
header set to start with www or contain a domain.tld type
of hostname, so your latest server block just catches everything
else (requests with missing Host headers, IP addresses,
nonwwwhostname.domain.tld hostnames etc.).

To put it simply - your configuration is wrong and should not
be used, unless you want to "deal with" the FBI in the near
future.

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

Regular Expression global redirect

altiamge February 25, 2012 10:59PM

Re: Regular Expression global redirect

António P. P. Almeida February 25, 2012 11:42PM

Re: Regular Expression global redirect

Edho Arief February 26, 2012 01:22AM

Re: Regular Expression global redirect

António P. P. Almeida February 26, 2012 09:40AM

Re: Regular Expression global redirect

Edho Arief February 26, 2012 09:44AM

Re: Regular Expression global redirect

altiamge February 26, 2012 02:27AM

Re: Regular Expression global redirect

altiamge February 26, 2012 06:39PM

Re: Regular Expression global redirect

Edho Arief February 26, 2012 02:30AM

Re: Regular Expression global redirect

António P. P. Almeida February 26, 2012 07:22PM

Re: Regular Expression global redirect

altiamge February 26, 2012 07:26PM

Re: Regular Expression global redirect

altiamge February 26, 2012 08:15PM

Re: Regular Expression global redirect

António P. P. Almeida February 26, 2012 07:42PM

Re[2]: Regular Expression global redirect

Max February 27, 2012 01:34AM

Re: Re[2]: Regular Expression global redirect

António P. P. Almeida February 27, 2012 05:14AM

Re[4]: Regular Expression global redirect

Max February 27, 2012 10:48PM

Re: Re[4]: Regular Expression global redirect

António P. P. Almeida February 28, 2012 07:12AM

Re: Regular Expression global redirect

Edho Arief February 26, 2012 01:12AM

Re: Regular Expression global redirect

Mark Alan February 26, 2012 07:20AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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