wildcard redirect

InterNetX - Jürgen Gotteswinter juergen.gotteswinter at internetx.de
Wed Aug 12 17:07:41 MSD 2009


2009/08/12 15:04:48 [notice] 16134#0: *76 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:48 [notice] 16134#0: *76 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host: "login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *78 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *78 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host: "login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *80 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *80 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host: "login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *82 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *82 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host: "login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *84 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *84 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host: "login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *86 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *86 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host: "login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *88 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *88 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host: "login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *90 "^/(.*)" matches "/", client: 
62.116.135.150, server: *.xxx.com, request: "GET / HTTP/1.0", host: 
"login.xxx.com"
2009/08/12 15:04:49 [notice] 16134#0: *90 rewritten redirect: 
"https://login.xxx.com/", client: 62.116.135.150, server: *.xxx.com, 
request: "GET / HTTP/1.0", host:


perhaps better readable @ http://de.pastebin.ca/1526481


Igor Sysoev wrote:
> On Wed, Aug 12, 2009 at 12:10:28PM +0200, Juergen Gotteswinter wrote:
> 
>> but it loops :(
>>
>> heres the full part incl. ssl part
>>
>>
>>   server {
>>         listen  xxx:80;
>>         server_name *.xxx.com;
>>
>>         rewrite ^/(.*) https://login.xxx.com$request_uri permanent;
>>     }
>>
>>
>>
>> server {
>>  listen               xxxxx:443;
>>  ssl                  on;
>>  ssl_protocols        SSLv3 TLSv1;
>>  ssl_ciphers         AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
>>  ssl_certificate      /etc/nginx/ssl/www.xxx.com.crt;
>>  ssl_certificate_key  /etc/nginx/ssl/www.xxx.com.key;
>>  ssl_session_cache    shared:SSL:10m;
>>  ssl_session_timeout  10m;
>>
>>
>>     server_name _;
>>         location / {
>>           proxy_pass http://www.xxx.com;
>>           access_log off;
>>           proxy_set_header X-Real-IP $remote_addr;
>>           proxy_set_header Host $host;
>>           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>         }
>>     }
> 
> It should work. Probably, redirect may be sent by backend.
> Could you create debug log of the looping request ?
> 
>> Igor Sysoev wrote:
>>> On Wed, Aug 12, 2009 at 11:21:13AM +0200, Juergen Gotteswinter wrote:
>>>
>>>> Hi Igor,
>>>>
>>>> i got something like
>>>>
>>>>  server {
>>>>        listen  xxx:80;
>>>>        server_name www.xxx.com xxx.com login.xxx.com;
>>>>
>>>>        rewrite ^ https://login.xxx.com$request_uri permanent;
>>>>    }
>>>>
>>>> if i add *.xxx.com, or remove the other entries in server_name and just 
>>>> leave *.xxx.com i get a redirect loop?
>>> No, since the redirect is to :443, but the server listens on :80.
>>>
>>>> sorry, but i'm lil bit confused now :)
>>>>
>>>> Igor Sysoev wrote:
>>>>> On Wed, Aug 12, 2009 at 09:20:37AM +0200, Juergen Gotteswinter wrote:
>>>>>
>>>>>> Hello Folks,
>>>>>>
>>>>>> is there a way to do a wildcard redirect like
>>>>>>
>>>>>> *.blafoo.com -> alwaysthis.com
>>>>>>
>>>>>> ?
>>>>> server {
>>>>>   server_name  *.blafoo.com;
>>>>>   rewrite      ^  http://alwaysthis.com/;
>>>>> }
>>>>>
>>>>>
> 

-- 
InterNetX GmbH
Maximilianstrasse 6
D-93047 Regensburg

Tel. +49 941 59559-480
Fax  +49 941 59559-245

Geschäftsführer/CEO: Thomas Mörz
Amtsgericht Regensburg, HRB 7142





More information about the nginx mailing list