wildcard redirect

Igor Sysoev is at rambler-co.ru
Wed Aug 12 14:21:01 MSD 2009


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/;
> >>>}
> >>>
> >>>
> >>

-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list