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?
大概是这样