nginx配置https,重定向后https變成了http


nginx配置https如下

nginx 后面應用是對應的tomcat應用

復制代碼
server {
    listen       80;
    server_name  xxxx.com;
    rewrite ^(.*) https://$server_name$1 permanent;
    }


server {
    listen    443 ssl;
    server_name  xxxx.com;
    ssl_certificate /app/nginx/1_xxxx.com_bundle.crt;
    ssl_certificate_key /app/nginx/2_xxxx.com.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    location /wxqyhweb {
        index index.html index.jsp;
        proxy_pass   http://10.1.0.3:8080/wxqyhweb;
        server_name_in_redirect off;
    ##    proxy_redirect   default ;
        proxy_redirect   http:// https://;
        proxy_set_header           Host $host:$server_port;
        proxy_set_header           X-Real-IP $remote_addr;
        proxy_set_header           X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size       888m;
        client_body_buffer_size    128k;
        proxy_connect_timeout      100;
        proxy_send_timeout         100;
        proxy_read_timeout         100;
        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }
復制代碼

nginx -t 測試配置文件沒有問題的就可以啟動了 

問題是:

 

 

把proxy_redirect default ;改成 proxy_redirect http:// https://;
這個配置是解決重定向后https變成了http 的問題。 
400 Bad Request: The plain HTTP request was sent to HTTPS port 
在重新測試一下就可以了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM