Service 同一服务器中具有基于web的用户界面的多个服务
我有一个具有多种服务和工具的服务器,具有基于web的用户界面(rundeck、jenkins、sonarqube等),我希望devteam可以使用正确的url访问,而不是使用服务器IP和端口。 即: -companyName-rundeck.com -companyName-jenkins.com -companyName-sonarqube.comService 同一服务器中具有基于web的用户界面的多个服务,service,server,dns,Service,Server,Dns,我有一个具有多种服务和工具的服务器,具有基于web的用户界面(rundeck、jenkins、sonarqube等),我希望devteam可以使用正确的url访问,而不是使用服务器IP和端口。 即: -companyName-rundeck.com -companyName-jenkins.com -companyName-sonarqube.com 做这件事的最佳方法是什么?最常用的方法是某种形式的。我将描述简单的Apache设置,但是使用nginx或HAProxy配置它应该同样容易 例如,让
做这件事的最佳方法是什么?最常用的方法是某种形式的。我将描述简单的Apache设置,但是使用nginx或HAProxy配置它应该同样容易 例如,让我们假设您在服务器上运行3个服务:
- 8080端口的詹金斯
- 在端口9000上
- 4440号港跑道甲板
jenkins.example.com A 192.0.2.2
sonar.example.com A 192.0.2.2
rundeck.example.com A 192.0.2.2
接下来,(如果尚未安装)安装Apache HTTP服务器:
yum install httpd
创建一个文件/etc/httpd/conf.d/proxy.conf
:
<VirtualHost *:80>
ServerName jenkins.example.com
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName sonar.example.com
ProxyPreserveHost On
ProxyPass / http://localhost:9000/
ProxyPassReverse / http://localhost:9000/
</VirtualHost>
<VirtualHost *:80>
ServerName rundeck.example.com
ProxyPreserveHost On
ProxyPass / http://localhost:4440/
ProxyPassReverse / http://localhost:4440/
</VirtualHost>
服务器名jenkins.example.com
代理主机
ProxyPass/http://localhost:8080/
ProxyPassReverse/http://localhost:8080/
ServerName sonar.example.com
代理主机
ProxyPass/http://localhost:9000/
ProxyPassReverse/http://localhost:9000/
ServerName rundeck.example.com
代理主机
ProxyPass/http://localhost:4440/
ProxyPassReverse/http://localhost:4440/
(逻辑应该非常清晰,详细解释请参见)
之后,只需启动httpd服务:服务httpd start
- 这些说明适用于CentOS,但对于其他发行版不应相差太多
- 如果它不能按预期工作(日志中没有任何明显的跟踪),请尝试禁用selinux(
&&setEnforce0
)service httpd restart