konfigurasi 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;
}
}
Gunakan pelayar untuk mengakses http://ip/jenkins, ia akan melompat ke http://ip/login?from=%2Fjenkins, dan ralat 404 akan muncul.
Tetapi gunakan konfigurasi nginx di bawah
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;
}
}
Apabila anda menggunakan pelayar untuk mengakses http://ip, ia akan melompat ke http://ip/login?from=%2Fjenkins, tetapi anda boleh mengaksesnya seperti biasa.
Jika saya ingin melaksanakan kaedah akses http://ip/jenkins, bagaimana untuk mengkonfigurasi nginx?
Mungkin begini