2012-12-06 7 views
1

사이트의 개발 및 준비 인스턴스를 모두 실행하는 서버가 있고 각 버전은 포트 80 & 443에 응답해야합니다. 준비 인스턴스는 예상대로 작동하지만, 그러나 각 사용자에 대해 구성된 개발 인스턴스는 두 프로토콜 중 하나의 페이지에서 직접 지정된 페이지를로드하지만, 한 포트의 페이지에서 다른 포트에 연결하려고하면 실패합니다.SSL 리디렉션 실패

내 구성

server { 
    listen 80; 
    server_name ~^dev\.(?<username>[^.]+)\.client\.tld\.net$ 
       ~^(?<username>[^.]+)\.client\.dev\.tld\.net$ 
       ~^(?<username>[^.]+)\.dev\.client\.tld\.net$; 

    location/{ 
     rewrite ^(.*) http://$username.client.tld.net$1 permanent; 
    } 
    } 
    # This is the primary host that will ultimately answer requests. 
    server { 
    listen  80; 
    server_name ~^(?<username>[^.]+)\.client\.tld\.net$; 
    root  /home/$username/client/www/app/webroot; 
    index  index.php; 

    access_log /var/log/nginx/client.sandbox.access.log; 
    error_log /var/log/nginx/client.sandbox.error.log; 

    location/{ 
     try_files $uri $uri/ /index.php?url=$uri; 
    } 

    location ~ \.php$ { 
     include /etc/nginx/conf/php; 
    } 

    include /etc/nginx/conf/expire_content; 
    include /etc/nginx/conf/ignore; 
    } 

    server { 
    listen 443 ssl; 
    server_name ~^dev\.(?<username>[^.]+)\.client\.tld\.net$ 
       ~^(?<username>[^.]+)\.client\.dev\.tld\.net$ 
       ~^(?<username>[^.]+)\.dev\.client\.tld\.net$; 

    location/{ 
    rewrite ^(.*) https://$username.client.tld.net$1 permanent; 
    } 
} 
# This is the primary host that will ultimately answer requests. 
server { 
    listen  443 ssl; 
    server_name ~^(?<username>[^.]+)\.client\.tld\.net$; 
    root  /home/$username/client/www/app/webroot; 
    index  index.php; 

    include /etc/nginx/conf/ssl; 

    access_log /var/log/nginx/client.sandbox.access.log; 
    error_log /var/log/nginx/client.sandbox.error.log; 

    location/{ 
    try_files $uri $uri/ /index.php?url=$uri; 
    } 

    location ~ \.php$ { 
    include /etc/nginx/conf/php; 
    } 

    include /etc/nginx/conf/expire_content; 
    include /etc/nginx/conf/ignore; 
} 

내가 내 설정을 borked 한 어떤 생각?

답변

2

우선 서버 (HTTP 및 HTTPS)가 모두 동일한 본문을 가지고 있기 때문에 4 개의 별도 구성을 만들 필요가 없습니다. 방금 작업중인 컨텍스트 (리디렉션의 경우)에 따라 http 또는 https을 포함하는 $scheme 변수를 사용할 수 있습니다. 둘째로 dev 구성에 어떤 root 선언도 표시되지 않으며 브라우저에 문제를 일으킬 수있는 인증서도 없습니다.

그 외의 구성은 괜찮아 보입니다. (음, index 선언을 http 구성으로 이동할 수 있으므로 항상 반복하지 않아도됩니다.)

내가 작성한 다음 (주석 처리 된) 구성 예를 확인하십시오. 어쩌면 도움이 될지도 모른다.

# Put this in http context! 
index   index.php; 

server { 
    # One server configuration to rule them all! 
    listen  80; 
    listen  443 ssl; 

    # Seems legit. 
    server_name ~^dev\.(?<username>[^.]+)\.client\.tld\.net$ 
       ~^(?<username>[^.]+)\.client\.dev\.tld\.net$ 
       ~^(?<username>[^.]+)\.dev\.client\.tld\.net$; 

    # Where am I? 
    #root   /home/$username/client/www/app/webroot; 

    # No wildcard certificate? No need to specify /etc/nginx as all paths 
    # in the configuration are relative to the installation path. 
    #include  conf/ssl; 

    location/{ 
    # May work as well, can't test. 
    #rewrite ^(.*) $scheme://$server_name$1 permanent; 
    rewrite ^(.*) $scheme://$username.client.tld.net$1 permanent; 
    } 
} 

server { 
    listen  80; 
    listen  443 ssl; 
    server_name ~^(?<username>[^.]+)\.client\.tld\.net$; 
    root   /home/$username/client/www/app/webroot; 
    include  conf/ssl; 
    access_log /var/log/nginx/client.sandbox.access.log; 
    error_log  /var/log/nginx/client.sandbox.error.log; 

    location/{ 
    try_files $uri $uri/ /index.php?url=$uri; 
    } 

    location ~ \.php$ { 
    include  conf/php; 
    } 

    include  conf/expire_content; 
    include  conf/ignore; 
}