Skip to end of metadata
Go to start of metadata

场景

通过在nginx中增加ssl证书认证,并将客户的请求转发到JIRA中。JIRA中无需再配置认证证书。

在以下配置过程中,我们假定需要进行的配置上下文件为

Confluence人访问地址为:http://confluence.hktxcn.com  现需要通过https来进行访问,即地址为:https://confluence.hktxcn.com

  • Confluence的IP地址为: 10.10.1.1 端口号为8090
  • Nginx的IP地址为: 20.20.1.1 端口号为80


信息来源

https://confluence.atlassian.com/doc/running-confluence-behind-nginx-with-ssl-858772080.html


步骤一:修改配置文件server.xml

<Server port="8000" shutdown="SHUTDOWN" debug="0">
    <Service name="Tomcat-Standalone">
        <!--
         =========
         DEFAULT - Direct connector with no proxy, for unproxied HTTP access to Confluence.

         If using a http/https proxy, comment out this connector.
         =========
        -->

       <!-- 需要将以下内容进行屏蔽-->
       

        <Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                   maxThreads="48" minSpareThreads="10"
                   enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                   protocol="org.apache.coyote.http11.Http11NioProtocol"/>
     

    <!-- 

=========
         HTTP - Proxying Confluence via Apache or Nginx over HTTP

         If you're proxying traffic to Confluence over HTTP, uncomment the connector below and comment out the others.
         Make sure you provide the right information for proxyName and proxyPort.

         For more information see:
            Apache - https://confluence.atlassian.com/x/4xQLM
            nginx  - https://confluence.atlassian.com/x/TgSvEg

=========
        -->

        <!--
        <Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                   maxThreads="48" minSpareThreads="10"
                   enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                   protocol="org.apache.coyote.http11.Http11NioProtocol"
                   scheme="http" proxyName="<subdomain>.<domain>.com" proxyPort="80"/>
        -->
        
        <!--
=========
         HTTPS - Direct connector with no proxy, for unproxied HTTPS access to Confluence.

         For more info see https://confluence.atlassian.com/x/s3UC
=========
        -->

        <!--
        <Connector port="8443" maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25"
                   protocol="org.apache.coyote.http11.Http11Nio2Protocol"
                   enableLookups="false" disableUploadTimeout="true"
                   acceptCount="100" scheme="https" secure="true"
                   clientAuth="false" sslProtocol="TLSv1.2" sslEnabledProtocols="TLSv1.2" SSLEnabled="true"
                   URIEncoding="UTF-8" keystorePass="<MY_CERTIFICATE_PASSWORD>"/>
        -->

        <!--
         =========
         HTTPS - Proxying Confluence via Apache or Nginx over HTTPS

         If you're proxying traffic to Confluence over HTTPS, uncomment the connector below and comment out the others.
         Make sure you provide the right information for proxyName and proxyPort.

         For more information see:
            Apache - https://confluence.atlassian.com/x/PTT3MQ
            nginx  - https://confluence.atlassian.com/x/cNIvMw
         =========
        -->
        <!-- 需要去掉以下屏蔽内容-->
        <!--
        <Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                   maxThreads="48" minSpareThreads="10"
                   enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                   protocol="org.apache.coyote.http11.Http11NioProtocol"
                   scheme="https" secure="true" proxyName="<subdomain>.<domain>.com" proxyPort="443"/>
        -->

        <Engine name="Standalone" defaultHost="localhost" debug="0">
            <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" startStopThreads="4">
                <Context path="" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true">
                    <!-- Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties -->
                    <Manager pathname=""/>
                    <Valve className="org.apache.catalina.valves.StuckThreadDetectionValve" threshold="60"/>
                </Context>

                <Context path="${confluence.context.path}/synchrony-proxy" docBase="../synchrony-proxy" debug="0"
                         reloadable="false" useHttpOnly="true">
                    <Valve className="org.apache.catalina.valves.StuckThreadDetectionValve" threshold="60"/>
                </Context>
            </Host>
        </Engine>
    </Service>
</Server>

<Server port="8000" shutdown="SHUTDOWN" debug="0">
    <Service name="Tomcat-Standalone">
        <!--
         =========
         DEFAULT - Direct connector with no proxy, for unproxied HTTP access to Confluence.

         If using a http/https proxy, comment out this connector.
         =========
        -->

        <!-- 需要将以下内容进行屏蔽-->

<!--
        <Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                   maxThreads="48" minSpareThreads="10"
                   enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                   protocol="org.apache.coyote.http11.Http11NioProtocol"/>

-->

<!--
        =========
         HTTP - Proxying Confluence via Apache or Nginx over HTTP

         If you're proxying traffic to Confluence over HTTP, uncomment the connector below and comment out the others.
         Make sure you provide the right information for proxyName and proxyPort.

         For more information see:
            Apache - https://confluence.atlassian.com/x/4xQLM
            nginx  - https://confluence.atlassian.com/x/TgSvEg

        =========
        -->
 
        <!--
        <Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                   maxThreads="48" minSpareThreads="10"
                   enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                   protocol="org.apache.coyote.http11.Http11NioProtocol"
                  scheme="http" proxyName="<subdomain>.<domain>.com" proxyPort="80"/>
        -->
        
        <!--
        =========
         HTTPS - Direct connector with no proxy, for unproxied HTTPS access to Confluence.

         For more info see https://confluence.atlassian.com/x/s3UC
      =========
        -->

        <!--
        <Connector port="8443" maxHttpHeaderSize="8192"
                   maxThreads="150" minSpareThreads="25"
                   protocol="org.apache.coyote.http11.Http11Nio2Protocol"
                   enableLookups="false" disableUploadTimeout="true"
                   acceptCount="100" scheme="https" secure="true"
                   clientAuth="false" sslProtocol="TLSv1.2" sslEnabledProtocols="TLSv1.2" SSLEnabled="true"
                   URIEncoding="UTF-8" keystorePass="<MY_CERTIFICATE_PASSWORD>"/>
        -->

        <!--
         =========
         HTTPS - Proxying Confluence via Apache or Nginx over HTTPS

         If you're proxying traffic to Confluence over HTTPS, uncomment the connector below and comment out the others.
         Make sure you provide the right information for proxyName and proxyPort.

         For more information see:
            Apache - https://confluence.atlassian.com/x/PTT3MQ
            nginx  - https://confluence.atlassian.com/x/cNIvMw
         =========
        -->
<!-- 需要去掉以下屏蔽内容,并填写代理域名-->
        <!-- -->
        <Connector port="8090" connectionTimeout="20000" redirectPort="8443"
                   maxThreads="48" minSpareThreads="10"
                   enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
                   protocol="org.apache.coyote.http11.Http11NioProtocol"
                   scheme="https" secure="true" proxyName="confluence.hktxcn.com" proxyPort="443"/>
      


        <Engine name="Standalone" defaultHost="localhost" debug="0">
            <Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" startStopThreads="4">
                <Context path="" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true">
                    <!-- Logging configuration for Confluence is specified in confluence/WEB-INF/classes/log4j.properties -->
                    <Manager pathname=""/>
                    <Valve className="org.apache.catalina.valves.StuckThreadDetectionValve" threshold="60"/>
                </Context>

                <Context path="${confluence.context.path}/synchrony-proxy" docBase="../synchrony-proxy" debug="0"
                         reloadable="false" useHttpOnly="true">
                    <Valve className="org.apache.catalina.valves.StuckThreadDetectionValve" threshold="60"/>
                </Context>
            </Host>
        </Engine>
    </Service>
</Server>


第三步

server {
    listen confluence.hktxcn.com:80;
    server_name confluence.hktxcn.com;
 
    listen 443 default ssl;
    ssl_certificate     /usr/local/etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /usr/local/etc/nginx/ssl/nginx.key;
 
    ssl_session_timeout  5m;

    location / {
        client_max_body_size 100m;
        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;
        proxy_pass http://10.10.1.1:8090;
    }
    location /synchrony {
        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;
        proxy_pass http://10.10.1.1:8091/synchrony;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}

说明



ssl_certificate和ssl_certificate_key填写证书存放的地址位置


这里指响应超时时间为5分钟





将请求转发到 http://10.10.1.1:8090地址上




将请求转发到 http://10.10.1.1:8090地址上






  • No labels