zoukankan      html  css  js  c++  java
  • Nginx + Tomcat + 的HTTPS 配置

    一、配置nginx

    1.将SSL证书放在 nginx/conf/cert 目录下。

    2.修改nginx.conf。配置实例:

    server {

    listen 443 ssl;

    server_name fssc.test.com; # 改为绑定证书的域名

    ssl_certificate cert/1582243.pem; # 改为自己申请得到的 pem 文件的路径

    ssl_certificate_key cert/1582243.key; # 改为自己申请得到的 key 文件的路径

    ssl_session_timeout 5m;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;

    ssl_prefer_server_ciphers on;

    location / {

         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_set_header Host $http_host;

            proxy_set_header X-Forwarded-Proto https;

            proxy_redirect off;

    }

    }

    3.配置修改完后,输入 ./nginx -s reload 重启Nginx。

    二、还需配置tomcat。

    将server.xml文件修改,实例如下:

    1.修改connector节点配置。

    <Connector port="8080" protocol="HTTP/1.1"

                   connectionTimeout="20000"

                   redirectPort="443"

                   proxyPort="443"/>

    2.添加value节点配置

       <Valve className="org.apache.catalina.valves.RemoteIpValve"

                      remoteIpHeader="x-forwarded-for"

                      remoteIpProxiesHeader="x-forwarded-by"

                      protocolHeader="x-forwarded-proto"/>

    参考:https://www.oschina.net/question/12_213459
     

    三、常见问题

    自己安装的nginx可能缺少ssl模块,导致nginx配置时报错。

    nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:37

    解决方法:nginx安装ssl模块。

    参考:https://blog.csdn.net/u011789653/article/details/77935166

  • 相关阅读:
    PhoneGap 数据库操作
    eclipse打开html文件
    Android 播放音频
    本地搭建 Apache 服务器
    C# CSV 导出
    .NET中使用MySQL数据库
    搭建一个phonegap环境,用eclipse+phonegap
    js test()
    Dom指针函数
    Js 禁用输入法 imemode 全角转换成半角
  • 原文地址:https://www.cnblogs.com/yfy-/p/10070653.html
Copyright © 2011-2022 走看看