confluence+nginx配置https

Running Confluence behind NGINX with SSL

中文标题【运行 Confluence 在 SSL 配置后的 NGINX】

这个页面描述了如何为 Confluence 配置 NGINX 的反向代理

这个页面中的配置结果将会影响到下面 2 个配置情况:

  • 外部客户连接到 NGINX 使用安全的 SSL。在 NGINX 和 Confluence 服务器之间的连接不是安全的。
  • Confluence 服务器和 NGINX 运行在同一个机器中。

 

 

本页中的内容:

我们假定你已经运行了 NGINX 实例。如果你还没有安装运行 NGINX 实例,请参考 NGINX documentation 文档中的内容来下载安装 NGINX。SSL 的证书也必须安装到 NGINX 运行的服务器上。你需要安装支持 WebSockets  的 NGINX 版本(1.3 或者后续版本)。

如果你的项目小组还计划使用 Confluence 的移动 app 版本,你还需要让你的证书从 CA(Certificate Authority) 授信。你不能在你的移动 APP 上使用自己签发的证书或者没有从 CA 授信的证书。

Atlassian Support 不能提供有关第三方工具的配置,例如 NGINX。如果你在配置的时候遇到了任何问题,请参考 NGINX 的文档,或者访问 Atlassian Community 或者从我们的 Solution Partner 合作伙伴处获得帮助。

 

1:设置上下文路径

 如果你不希望通过上下文来访问你的 Confluence 安装实例(www.example.com),或者你是直接通过子域名来访问的(confluence.example.com),你可以跳过这一步的配置。

Tomcat 中设置你 Confluence 应用程序的路径(位于主机名和端口后的路径)。编辑 <installation-directory>/conf/server.xml,这部分内容在 "Context" 中定义:

<Context path="" docBase="../confluence" debug="0" reloadable="false">

然后修改为:

<Context path="/confluence" docBase="../confluence" debug="0" reloadable="false">

在这个示例中,我们已经使用了 /confluence 为上下文的路径。请注意,你不能使用 /resources 为你的上下文路径,因为在 Confluence 中使用这个路径用于定位资源,如果你使用这个路径的话将会在后面导致错误。

重启 Confluence,然后检查你是否可以访问 http://example:8090/confluence

2:配置 Tomcat 连接器

在相同的 <installation-directory>conf/server.xml 文件中,使用示例的连接器为启动点。

注释掉默认的连接器(针对不需要代理的访问)。

Show me how to do this...

XML 文件中,注释是以 <!-- 开始的,以 -->  结束的。注释掉的部分在 Confluence 应用程序读取配置文件的时候将会忽略。

添加 <!--  --> 默认的连接器。文件现在应该看起来如下所示。

<!--

========================================================

DEFAULT - Direct connector with no proxy, for unproxied HTTP access to Confluence.

========================================================

-->

<!--

<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"/>

-->

取消  HTTPS - Proxying Confluence via Apache or Nginx over HTTPS 中间的注释。

Show me how to do this...

取消注释的部分,你只需要删除 <!--  --> 包含的连接器注释就可以了。

下面显示的是默认连接器被注释掉,但是 HTTPS 连接器没有被注释。头部同时保留注释。

<!--

========================================================

DEFAULT - Direct connector with no proxy, for unproxied HTTP access to Confluence.

========================================================

-->

<!--

<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"/>

-->

...

<!--

========================================================

HTTPS - Proxying Confluence via Apache or Nginx over HTTPS

========================================================

-->

<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"/>

插入你的 代理名(proxyName 代理端口(proxyPort 如下行显示的内容:

<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="www.example.com" proxyPort="443"/>

请确定你已经为你的协议和代理名称配置了争取的值。

3:配置 NGINX

你需要在你的的 NGINX 服务器中指定一个监听服务器,如下面的示例内容。同时添加下面的内容到你的 NGINX 配置中。

替换你 SSL 证书和 key 为你的服务器名称。

在这个示例中,用户将要连接到 Synchrony,这个服务运行直接协作编辑。

server {

    listen www.example.com:80;

    server_name www.example.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;

 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-

POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:

ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-

AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-

AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-

ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-

RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-

SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-

SHA:!DSS';

    ssl_prefer_server_ciphers   on;

 

    location /confluence {

        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://localhost:8090/confluence;

    }

    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://localhost:8091/synchrony;

        proxy_http_version 1.1;

        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "Upgrade";

    }

}

请参考 https://nginx.org/en/docs/http/ngx_http_proxy_module.html 来获得更多的信息。

备注:如果你现在正在配置 SSL 和 Confluence 到一个相同的服务器上,如上面的内容所示,请不要包含 ssl 配置。

如果你不确定在那里包含 ssl_ciphers,请参考页面 https://mozilla.github.io/server-side-tls/ssl-config-generator/ 中的内容,这里的内容能非常有用。

如果你遇到了 413 Request Entity Too Large 的错误,请确定 /confluence 中的 client_max_body_size 块内容与 Confluence 的 maximum attachment size 配置的大小是相同的。如果你在对大页面进行编辑的时候遇到了错误,你可能还需要增加 /synchrony 中配置的 client_max_body_size 大小。

如果你计划使用 Confluence 的移动 app...

如果你允许在 Confluence 使用移动 app,同时你还配置了你的 Confluence 上下文,如上面的配置所示,你可能还需要添加下面的行到你的 nginx 配置中。

location /server-info.action {

     proxy_pass   http://localhost:8090/confluence/server-info.action;

}

如果你通过子域名来访问 Confluence ...

如果你已经通过子域名来访问 Confluence ,你的配置看起来如下所示:

server {

    listen confluence.example.com:80;

    server_name confluence.example.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;

 

     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-

POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:

ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-

AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-

AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-

ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-

RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-

SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-

SHA:!DSS';

    ssl_prefer_server_ciphers   on;

 

    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://localhost: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://localhost:8091/synchrony;

        proxy_http_version 1.1;

        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "Upgrade";

    }

}

 

4:重启 Confluence 和 NGINX

  1. 重启 Confluence 和 NGINX 来让配置生效。
  2. 更新 Confluence 的基础 URL 来确定你在上下文问中设置的路径,请参考 Configuring the Server Base URL 页面中的内容。

猜你喜欢

转载自www.cnblogs.com/lixiaoran/p/12134531.html