在這些示例中,咱們使用下面的信息:java
http://www.example.com/confluence - 你計劃使用的 URLapache
http://example:8090/ - Confluence 當前安裝的主機名和端口服務器
http://example:8091/ - Synchrony 當前安裝的主機名和端口,這個服務被用來提供默認的協同編輯服務dom
/confluence - 這個是有關你 Confluence 計劃使用的上下文(在主機名和端口的後面)eclipse
/synchrony - Synchrony 使用的上下文路徑,這個提供了協同編輯服務ui
你須要將上面的 URL 替換成你本身的 URL。this
若是你不須要使用上下文來訪問 Confluence,例如你但願使用 www.example.com 來訪問這個,你能夠跳過這部分的內容。url
設置你 Tomcat 中 Confluence 上下文的路徑(在主機名和端口的後面)。在這個示例中,上下文路徑被配置爲 /confluence。
spa
編輯 <installation-directory>conf/server.xml,找到
"Context" 的定義:操作系統
<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 進行訪問,並確保你能正確訪問。
下一步,設置 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"
|
若是你計劃啓用 HTTPS,使用 HTTPS - Proxying Confluence via Apache or Nginx over HTTPS. 下面的鏈接器。
使用下面的一個示例來編輯你的 http.conf
文件中有關應用服務器代理的配置。
你須要針對你的 Apache 啓用下面的一些模塊,若是這些模塊尚未在你的 Apache 中啓用的話:
(proxy_wstunnel 和 mod_rewrite 是針對 Confluence 6.0 須要的新的模塊)
http.conf
文件的格式和模塊的位置路徑,針對你使用操做系統的不一樣可能有所不一樣。大家推薦 Windows 的用戶在這裏配置的時候使用絕對路徑。
在這個示例中,若是你已經在上面的第一步中設置了上下文路徑,同時你的 Confluence 服務器也能夠經過配置的上下文路徑進行訪問,例如這個 http://www.example.com/confluence。
在這個示例中,用戶將會鏈接到 Synchrony,這個是針對協同編輯所使用的服務,是經過 WebSockets 直連的。
在配置文件中的配置順序是很是重要的。
# 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 或者後續版本。
在這個示例中,若是你已經跳過了第一步的配置,沒有使用上下文路徑進行訪問,例如訪問的 URL 爲 http://www.example.com/。
在這個示例中,用戶將會鏈接到 Synchrony,這個是針對協同編輯所使用的服務,是經過 WebSockets 直連的。
在配置文件中的配置順序是很是重要的。
# 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 或者後續版本。
爲了讓新的配置生效,你須要運行下面的命令來讓 Apache 重啓後載入新的配置文件:
sudo apachectl graceful
|
若是在代理和 Tomcat 中啓用了壓縮,這個將會在整合其餘 Atlassian 應用的時候出現問題,例如 JIRA。請禁用 HTTP 壓縮,並請參考 Compressing an HTTP Response within Confluence 頁面中的內容。
最後一個步驟是配置 Base URL 的地址來指向你沒有使用的代理的地址,例如 http://www.example.com/confluence。
https://www.cwiki.us/display/CONF6ZH/Using+Apache+with+mod_proxy