2016-02-22 113 views
1

我想配置Nginx,以便終止SSL,然後通過http將請求轉發到後端Tomcat服務器。當我嘗試登錄時,我被重定向迴應用程序,但出現以下異常。Nginx SSL終止代理到tomcat 8

「HTTP狀態500 - javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路徑構建失敗:sun.security.provider.certpath.SunCertPathBuilderException:無法找到有效的證書路徑以請求目標」

我正在使用jasig cas。

Nginx的配置

#Load balancing group 
upstream main_lb_group { 
    ip_hash; 
    server 127.0.0.1:8080; 
    server 127.0.0.1:8081; 
} 

#Redirecting HTTP to HTTPS requests 
server { 
     listen 80; 
     return 301  https://$host$request_uri; 
} 

#Where users access applications, im using subdomain but it could be the main site 
server { 
     listen 443 ssl; 
     server_name subdomain.abc.com; 

     location/{ 
       proxy_pass http://main_lb_group; 
       proxy_set_header X-Forwarded-Host $host; 
       proxy_set_header X-Forwarded-Server $host; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     } 
} 

#Tomcat management page for server 1 has its own subdomain backend1.abc.com 
server { 
     listen 443 ssl; 
     server_name backend1.abc.com; 

     root /opt/tomcat8b1/webapps/; 
     index index.jsp index.html index.htm; 

     location/{ 
       proxy_pass http://127.0.0.1:8080/; 
       proxy_connect_timeout  300; 
       proxy_send_timeout   300; 
       proxy_read_timeout   300; 
       send_timeout    300; 
     } 

     location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { 
       expires 1M; 
     } 
} 

#Tomcat management page for server 2 has its own subdomain backend2.abc.com 
server { 
     listen 443 ssl; 
     server_name backend2.abc.com; 

     root /opt/tomcat8b2/webapps/; 
     index index.jsp index.html index.htm; 

     location/{ 
       proxy_pass http://127.0.0.1:8081/; 
       proxy_connect_timeout  300; 
       proxy_send_timeout   300; 
       proxy_read_timeout   300; 
       send_timeout    300; 
     } 

     location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { 
       expires 1M; 
     } 
} 

誰能幫助嗎?

回答

0

原來cas服務器在服務器名稱屬性鏈接中使用http而不是https。將其更改爲https後,它可以正常工作。