在这些示例中,咱们使用下面的信息:apache
http://www.example.com/confluence - 你计划使用的 URL服务器
http://example:8090/ - Confluence 当前安装的主机名和端口dom
http://example:8091/ - Synchrony 当前安装的主机名和端口,这个服务被用来提供默认的协同编辑服务ui
/confluence - 这个是有关你 Confluence 计划使用的上下文(在主机名和端口的后面)this
/synchrony - Synchrony 使用的上下文路径,这个提供了协同编辑服务spa
你须要将上面的 URL 替换成你本身的 URL。操作系统
1 设置上下文路径
若是你不须要使用上下文来访问 Confluence,例如你但愿使用 www.example.com 来访问这个,你能够跳过这部分的内容。debug
设置你 Tomcat 中 Confluence 上下文的路径(在主机名和端口的后面)。在这个示例中,上下文路径被配置为 /confluence。
代理
编辑 <installation-directory>conf/server.xml,找到
"Context" 的定义:code
<Context path= "" docBase= "../confluence" debug= "0" reloadable= "true" > |
而后修改成:
<Context path= "/confluence" docBase= "../confluence" debug= "0" reloadable= "true" > |
在这个示例中,咱们已经使用了 /confluence
为上下文的路径。请注意,你不能使用 /resources
为你的上下文路径,这是由于这个上下文的路径在 Confluence 中被用来定义资源,若是你使用这个配置的话,将会在 Confluence 中致使问题。
重启 Confluence,而后你能够尝试使用 http://example:8090/confluence 进行访问,并确保你能正确访问。
2 设置 URL 重定向
下一步,设置 URL 重定向。在 <installation-directory>conf/server.xml
文件中,使用示例的链接器为你的起始点。
注释掉默认的链接器(针对不使用代理的访问)。
显示如何进行配置..
在 HTTP - Proxying Confluence via Apache or Nginx over HTTP 头部列出的内容,取消注释链接器。
显示如何进行配置..
在上面显示内容的最下面,插入你的 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= "http" proxyName= "www.example.com" proxyPort= "80" /> |
若是你计划启用 HTTPS,使用 HTTPS - Proxying Confluence via Apache or Nginx over HTTPS. 下面的链接器。
3 配置 mod_proxy
使用下面的一个示例来编辑你的 http.conf
文件中有关应用服务器代理的配置。
你须要针对你的 Apache 启用下面的一些模块,若是这些模块尚未在你的 Apache 中启用的话:
- mod_proxy
- mod_proxy_http
- proxy_wstunnel
- mod_rewrite
(proxy_wstunnel 和 mod_rewrite 是针对 Confluence 6.0 须要的新的模块)
http.conf
文件的格式和模块的位置路径,针对你使用操做系统的不一样可能有所不一样。大家推荐 Windows 的用户在这里配置的时候使用绝对路径。
示例 1:配置上下文路径
在这个示例中,若是你已经在上面的第一步中设置了上下文路径,同时你的 Confluence 服务器也能够经过配置的上下文路径进行访问,例如这个 http://www.example.com/confluence。
在这个示例中,用户将会链接到 Synchrony,这个是针对协同编辑所使用的服务,是经过 WebSockets 直连的。
在配置文件中的配置顺序是很是重要的。
Apache HTTP server 2.4
# Put this after the other LoadModule directives LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so # Put this in the main section of your configuration (or virtual host, if using Apache virtual hosts) ProxyRequests Off ProxyPreserveHost On <Proxy *> Require all granted </Proxy> ProxyPass /synchrony http: //<domain>:8091/synchrony <Location /synchrony> Require all granted RewriteEngine on RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC] RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC] RewriteRule .* ws: //<domain>:8091%{REQUEST_URI} [P] </Location> ProxyPass /confluence http: //<domain>:8090/confluence ProxyPassReverse /confluence http: //<domain>:8090/confluence <Location /confluence> Require all granted </Location> |
注意:若是你使用的是 HTTP Server 2.2,可是你的 Confluence 使用的 6.0 及其后续版本,这个配置是不能成功的。若是你计划使用 SSL ,你须要使用 2.4.10 或者后续版本。
示例 2:不使用上下文的配置
在这个示例中,若是你已经跳过了第一步的配置,没有使用上下文路径进行访问,例如访问的 URL 为 http://www.example.com/。
在这个示例中,用户将会链接到 Synchrony,这个是针对协同编辑所使用的服务,是经过 WebSockets 直连的。
在配置文件中的配置顺序是很是重要的。
Apache HTTP server 2.4
# Put this after the other LoadModule directives LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so # Put this in the main section of your configuration (or virtual host, if using Apache virtual hosts) ProxyRequests Off ProxyPreserveHost On RewriteEngine On RewriteCond %{REQUEST_URI} !^/synchrony RewriteRule ^/(.*) http: //<domain>:8090/$1 [P] <Proxy *> Require all granted </Proxy> ProxyPass /synchrony http: //<domain>:8091/synchrony <Location /synchrony> Require all granted RewriteEngine on RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC] RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC] RewriteRule .* ws: //<domain>:8091%{REQUEST_URI} [P] </Location> ProxyPass / http: //<domain>:8090 ProxyPassReverse / http: //<domain>:8090 <Location /> Require all granted </Location> |
注意:若是你使用的是 HTTP Server 2.2,可是你的 Confluence 使用的 6.0 及其后续版本,这个配置是不能成功的。若是你计划使用 SSL ,你须要使用 2.4.10 或者后续版本。
4 重启 Apache
为了让新的配置生效,你须要运行下面的命令来让 Apache 重启后载入新的配置文件:
5 禁用 HTTP 压缩
若是在代理和 Tomcat 中启用了压缩,这个将会在整合其余 Atlassian 应用的时候出现问题,例如 JIRA。请禁用 HTTP 压缩,并请参考 Compressing an HTTP Response within Confluence 页面中的内容。
6 修改 Confluence 基础 URL
最后一个步骤是配置 Base URL 的地址来指向你没有使用的代理的地址,例如 http://www.example.com/confluence。
https://www.cwiki.us/display/CONF6ZH/Using+Apache+with+mod_proxy