2010-12-01 7 views
3

HTTPS를 통해 액세스 할 때 동일한 하위 도메인으로 리디렉션해야하는 여러 개의 와일드 카드 하위 도메인 (_foo.example.com, bar.example.com 등)이 있습니다. 우리의 보안 도메인.와일드 카드 하위 도메인을 nginx를 사용하여 다른 최상위 도메인으로 리디렉션

몇 가지 예 :

나는이이 nginx를 재 작성으로 수행 할 수 있다고 생각

하지만 난 구문에 대해 확실하지 않습니다. 여기에 내가 시도하고있는 무슨이다 :

server { 
    listen  443; 
    server_name *.example.com; 

    rewrite  ^(.*) https://*.secure.com$1 permanent; 
} 

내가 들어오는 하위 도메인을 캡처하고 다시 작성을 사용하지 않는 때문에 분명히 작동하지 않습니다. 이 (안된) 같은

답변

3

시도 뭔가 : 찾을 수

server { 
    listen 80; 
    listen 443 default ssl; 

    server_name "~^(?<name>\w\d+)\.example\.com$"; 

    rewrite ^(.*) https://$name.secure.com$1 permanent; 
} 
+0

에 나는이 솔루션을 좋아하고 그것은 (많이 내 자신의 목적을 위해 수정) 나를 위해 일하고있다. – Pablo

1

http://forum.slicehost.com/comments.php?DiscussionID=730

# redirects arbitrary subdomain (some.random.sub.example.com) to (some.random.sub.example.org) 
if ($host ~* "^([^.]+(\.[^.]+)*)\.example.com$"){ 
    set $subd $1; 
    rewrite ^(.*)$ http://$subd.example.org$1 permanent; 
    break; 
} 

# Simply redirects example.com to example.org 
if ($host ~* "^example.com$"){ 
    rewrite ^(.*)$ http://example.org$1 permanent; 
    break; 
} 
관련 문제