使用nginx反向代理出现jenkins出现404错误
PHPz
PHPz 2017-05-16 17:14:58
0
1
1813

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;
    }
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板