404 error occurs in jenkins using nginx reverse proxy
PHPz
PHPz 2017-05-16 17:14:58
0
1
1756

nginx configuration:

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;
    }
  }

Use a browser to access http://ip/jenkins, it will jump to http://ip/login?from=%2Fjenkins, and a 404 error will appear.

But use the nginx configuration below

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;
    }
  }

Using a browser to access http://ip will jump to http://ip/login?from=%2Fjenkins, but it can be accessed normally. Why is this?

If I want to implement http://ip/jenkins access method, how to configure nginx?

PHPz
PHPz

学习是最好的投资!

reply all(1)
習慣沉默

Probably like this

server{
    location / {
        try_files $uri @jenkins;
     }
     
    location @jenkins {
        internal;
        proxy_pass http://127.0.0.1:8080;
    }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!