Nginx跳转配置

丶灬走出姿态 提交于 2021-01-23 21:15:30

 

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

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!