默认访问Confluence时,需要使用8090端口访问,为了更方便访问使用,本文使用Nginx基于http协议做反向代理,通过80端口访问Confluence,本文基于Confluence7.4版本进行验证,理论适用于所有版本,其他版本请自行验证!
编辑Confluence的Tomcat配置文件
1 |
vim /opt/atlassian/confluence/conf/server.xml |
找到以下字段
1 2 3 4 |
<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"/> |
更改成你要反向代理的域名,注意结尾的/>
1 2 3 4 5 |
<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="wiki.whsir.com" proxyPort="80"/> |
保存退出,重启服务
1 |
/etc/init.d/confluence restart |
安装配置nginx反向代理
1 |
rpm -ivh https://mirrors.wlnmp.com/centos/wlnmp-release-centos.noarch.rpm |
1 |
vim /usr/local/nginx/conf/vhost/demo.conf |
将原有内容删除,改成以下内容(wiki.whsir.com自己更改)
以下配置内容适用于Confluence 6.0及更高版本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
server { listen 80; server_name wiki.whsir.com; 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 { 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:8091/synchrony; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } } |
如果是Confluence 5.10及更早版本请使用以下配置:
1 2 3 4 5 6 7 8 9 10 |
server { listen 80; server_name wiki.whsir.com; location / { 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; } } |
保存退出,重启Nginx
1 2 |
nginx -t /etc/init.d/nginx restart |
登录ConfluenceWEB,设置基本URL
在一般配置→站点配置→修改服务器主页URL地址,保存
原文链接:使用Nginx通过http协议反向代理Confluence,转载请注明来源!