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?
習慣沉默2017-05-16 17:16:58
Probably like this
server{
location / {
try_files $uri @jenkins;
}
location @jenkins {
internal;
proxy_pass http://127.0.0.1:8080;
}
}