我在一台机器上安装了一个sonarqube和一台Jenkins服务器,分别有端口9000和8080。我想制作像test_hub.mysite.com/sonar和/ jenkins这样的网址并正确地重定向到机器和端口,但保留原始地址test_hub.mysite.com/sonar。
我使用nginx的配置非常简单:
server {
listen 80;
server_name sonar.mysite.com;
location /sonar/ {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://52.29.xx.xx:9000;
}
}
答案 0 :(得分:-1)
server {
listen 80;
server_name test_hub.mysite.com;
location / {
# you can use regular exp also
if ($request_uri = /sonar) {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://52.29.xx.xx:9000;
}
if ($request_uri = /jenkins) {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://52.29.xx.xx:8000;
}
}
}
注意:在尝试
之前,请先检查此link