zoukankan      html  css  js  c++  java
  • nginx 配置https 并解决重定向后https协议变成了http的问题

    配置如下: 

    server { 
        listen       80; 
        server_name  localhost; 
         
         return 301 https://localhost$request_uri; 
         charset UTF-8; 


        location / { 
          root   html;                  # 这个是指定一个项目所在目录 
          index  index.html index.htm;  # 这个是指定首页的文件名 
        } 



    server { 
        listen       80 default backlog=2048; 
        listen       443 ssl; 
        server_name  localhost; 

        ssl_certificate      buduhuisi.crt;  # 这个是证书的crt文件所在目录 
        ssl_certificate_key  buduhuisi.key;  # 这个是证书key文件所在目录 

        ssl_session_cache    shared:SSL:1m; 
        ssl_session_timeout  5m; 

        ssl_ciphers  HIGH:!aNULL:!MD5; 
        ssl_prefer_server_ciphers  on; 

        location /esgcc-oms { 
                            proxy_pass         http://localhost:8080; 
                        proxy_redirect http:// https://; 
                            add_header         Cache-Control    no-store; 
                            proxy_set_header   Host             $host; 
                            proxy_set_header   X-Real-IP        $remote_addr; 
                            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; 

                 } 

        location / { 
          root   html;                  # 这个是指定一个项目所在目录 
          index  index.html index.htm;  # 这个是指定首页的文件名 
        } 




    proxy_redirect http:// https:// 这个配置是解决重定向后https变成了http 的问题。 

    应用中配置: 
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
            <property name="prefix" value="/pages/" /> 
            <property name="suffix" value=".jsp" /> 
            <property name="order" value="1" /> 
            <property name="redirectHttp10Compatible" value="false" />   <!--重定向解决https 变成了http 的问题--> 
        </bean> 



    可以解决这个问题: 
    400 Bad Request: The plain HTTP request was sent to HTTPS port 

  • 相关阅读:
    今日头条核心技术“个性推荐算法”揭秘
    今日头条架构演进之路
    今日头条的核心架构解析
    Retrofit2+Rxjava+MVP实践
    Android MVP 构架封装
    Android MVP 构架初试
    C++ tinyXML的使用和字符编码转换
    C++tinyXML使用
    代码实现文件驱动的安装 (转载)
    SC命令---安装、开启、配置、关闭windows服务 bat批处理(转载)
  • 原文地址:https://www.cnblogs.com/lvjijun/p/11320276.html
Copyright © 2011-2022 走看看