1.携带目录调转到后端,后端无目录,location配置如下
例子: i2.jusdacfj.com/ideas_edi/——10.0.2.137:7040/10.0.2.138:7040
location ^~/ideas_edi/ { ##携带"/"
proxy_pass http://edi1/; ##携带"/"
proxy_redirect off;
proxy_set_header Host $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
2.携带目录调转到后端,后端有目录,location配置如下
例子: i2.jusdacfj.com/ideas_file/——10.0.2.138:7051/ideas_file/
location ^~/ideas_task { ##ideas_task后面无需"/"
proxy_pass http://task1/; ##task1后面添加"/"
proxy_redirect off;
proxy_set_header Host $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
来源:oschina
链接:https://my.oschina.net/u/4309324/blog/4078803