运行 Confluence 6 在 SSL 配置后的 NGINX

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

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

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

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

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

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

1:设置上下文路径

(warning) 若是你不但愿经过上下文来访问你的 Confluence 安装实例(www.example.com),或者你是直接经过子域名来访问的(confluence.example.com),你能够跳过这一步的配置。安全

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

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

而后修改成:app

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

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

重启 Confluence,而后检查你是否能够访问 http://example:8090/confluence

2:配置 Tomcat 链接器

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

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

Show me how to do this...

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

Show me how to do this...

插入你的 代理名(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 ...

4:重启 Confluence 和 NGINX

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

https://www.cwiki.us/display/CONF6ZH/Running+Confluence+behind+NGINX+with+SSL

相关文章
相关标签/搜索