前言
wekan使用的是8080端口,这样通过浏览器访问就存在下面问题:
我通过浏览器访问就得在IP后面加上8080端口号才能访问便
现在都是域名,谁会在浏览器输入IP
服务开放的端口越多越不安全
要解决这些问题,就得通过Web服务器的反向代理来实现。
这里我介绍下如何使用Apache httpd Web服务器实现发现代理非80端口和二级域名配置。
一、使用步骤
添加域名解析,我这里使用的是阿里云,我把wekan添加到一个二级域名wekan.xxx.com
先查看wekan使用的端口,确认为docker中运行的wekan使用8080端口,映射到本机的也是8080端。
确认网站可以访问,执行如下命令进行访问测试:curl http://127.0.0.1:8080
配置httpd反向代理,编辑httpd.conf:sudo vim /etc/httpd/conf/httpd.conf
添加配置如下:
<VirtualHost *:80>
ServerName wekan.xxx.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
或
<VirtualHost *:80>
ServerName wekan.xxx.com
ServerAlias wekan.xxx.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
</VirtualHost>
重启httpd服务sudo systemctl restart httpd.service
打开浏览器访问wekan.xxx.com