通過https訪問2級域名,來反向代理到各個不同的tomcat應用

參考閱讀 http://www.jianshu.com/p/fd18af018467

nginx的配置文件的內容

主要是在nginx.conf文件中配置不同的proxy,並且通過server_name 來區分訪問的網站的不同的二級域名。

#whale 基酒貸項目的tomcat反向代理
upstream whale-tomcat {
    #ip_hash;
    server 10.46.89.165:10443 max_fails=2 fail_timeout=30s;
}

#terrier 統一用戶管理項目的tomcat反向代理
upstream terrier-tomcat {
    #ip_hash;
    server 10.46.89.165:38080 max_fails=2 fail_timeout=30s;
}

server {
    listen 443; 
    server_name www.jijiuzaixian.com;
    ssl on;
    index index.jsp index.html index.htm;
    ssl_certificate   /etc/nginx/conf.d/213981816970139.pem;
    ssl_certificate_key  /etc/nginx/conf.d/213981816970139.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
    ssl_prefer_server_ciphers on;
    location / {
        root   jsp;
        index  index.jsp index.html index.htm;
        proxy_pass  https://whale-tomcat;
        proxy_set_header Host  $http_host;
        proxy_set_header Cookie $http_cookie;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size  100m;
    }
}

server {
    listen 443; 
    server_name passport.jijiuzaixian.com;
    ssl on;
    index index.jsp index.html index.htm;
    ssl_certificate   /etc/nginx/conf.d/213981816970139.pem;
    ssl_certificate_key  /etc/nginx/conf.d/213981816970139.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
    ssl_prefer_server_ciphers on;
    location / {
        root   jsp;
        index  index.jsp index.html index.htm;
        proxy_pass  https://terrier-tomcat;
        proxy_set_header Host  $http_host;
        proxy_set_header Cookie $http_cookie;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        client_max_body_size  100m;
    }    
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章