使用nginx反向代理出現jenkins出現404錯誤
PHPz
PHPz 2017-05-16 17:14:58
0
1
1896

nginx配置:

server {

    listen 80;
    server_name localhost;

    location /jenkins {

      proxy_set_header        Host $host:$server_port;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://127.0.0.1:8081;
      proxy_read_timeout  90;
    }
  }

使用瀏覽器造訪http://ip/jenkins,會跳到http://ip/login?from=%2Fjenkins,出現404錯誤。

但使用下面的nginx配置

server {

    listen 80;
    server_name localhost;

    location / {

      proxy_set_header        Host $host:$server_port;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://127.0.0.1:8081;
      proxy_read_timeout  90;
    }
  }

使用瀏覽器訪問http://ip,會跳到http://ip/login?from=%2Fjenkins,但是能正常訪問,這是為什麼呢?

想實作http://ip/jenkins這種存取方式,要怎麼設定nginx?

PHPz
PHPz

学习是最好的投资!

全部回覆(1)
習慣沉默

大概是這樣

server{
    location / {
        try_files $uri @jenkins;
     }
     
    location @jenkins {
        internal;
        proxy_pass http://127.0.0.1:8080;
    }
}
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板