假设我http://localhost:8080
指向我的 Jenkins 实例并http://localhost:8081
指向我的 Jira 实例,我需要做什么才能访问我的服务http://localhost/jenkins
并http://localhost/jira
使用默认端口 80?这在 Ubuntu 中可行吗?
答案1
NGINX 作为反向代理运行的配置片段
http {
# Some standard NGINX config stuff goes here
...
# Listen on port 80
server {
listen 80;
server_name my.awesome.domain.com;
# Proxy /jenkins to localhost port 8080
location /jenkins {
proxy_pass http://localhost:8080;
}
# Proxy /jira to localhost port 8081
location /jira {
proxy_pass http://localhost:8081;
}
}
}
查看NGINX文档以获取更多信息。
Apache 作为反向代理运行的配置片段
# First load the reverse proxy modules
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
# Make sure we're listening on port 80
Listen 80
# Define a default vHost
<VirtualHost *:80>
# Standard vhost stuff goes here if required
# Probably should have something to handle / requests at least
....
# Reverse proxy for Jenkins
ProxyPass /jenkins http://localhost:8080
ProxyPassReverse /jenkins http://localhost:8080
# Reverse proxy for Jira
ProxyPass /jira http://localhost:8081
ProxyPassReverse /jira http://localhost:8081
</VirtualHost>
查看阿帕奇文档了解更多信息
答案2
您需要一个正确配置的、能够代理的 Web 服务器(例如 Apache、Nginx)来监听 localhost:80。