log_format szxw_timed_combined '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time';#外部转发
server {listen 7999;server_name localhost;#log_format timed_combined '$request_time';access_log logs/szxw.access.log szxw_timed_combined;underscores_in_headers on;send_timeout 60s;client_header_timeout 60s;client_body_timeout 60s;client_max_body_size 4096m;client_body_buffer_size 4096m; #e签宝location ^~ /esign{rewrite ^/esign/(.*)$ /$1 break;proxy_pass https://smlopenapi.esign.cn;proxy_http_version 1.1;proxy_read_timeout 320s;proxy_connect_timeout 75s;#proxy_set_header Host "rds-t.baihangcredit.com";#proxy_set_header Upgrade $http_upgrade;#proxy_set_header Connection "Upgrade";#proxy_set_header X-real-ip $remote_addr;#proxy_set_header X-Forwarded-For $remote_addr;}#e签宝location ^~ /tsign{rewrite ^/tsign/(.*)$ /$1 break;proxy_pass http://smlitsm.tsign.cn:8080;proxy_http_version 1.1;proxy_read_timeout 320s;proxy_connect_timeout 75s;}#e签宝location /openapi_tech{proxy_pass http://smltech.tsign.cn:8080;proxy_http_version 1.1;proxy_read_timeout 120s;proxy_connect_timeout 75s;}}
部分:
#e签宝location ^~ /tsign{rewrite ^/tsign/(.*)$ /$1 break;proxy_pass http://smlitsm.tsign.cn:8080;proxy_http_version 1.1;proxy_read_timeout 320s;proxy_connect_timeout 75s;}
意思是访问路径有/tsign的,通过rewrite 用proxy_pass 的值拼上/tsign后面的值
还有种写法:
#e签宝location /tsign{proxy_pass http://smlitsm.tsign.cn:8080/;proxy_http_version 1.1;proxy_read_timeout 320s;proxy_connect_timeout 75s;}
这两种写法同效,但如果访问路径不想过滤掉 /tsign
就写成:
#e签宝location /tsign{proxy_pass http://smlitsm.tsign.cn:8080;proxy_http_version 1.1;proxy_read_timeout 320s;proxy_connect_timeout 75s;}
注意:proxy_pass后面没有/
修改完conf后要重启才生效