nginx重发机制

如题: 如果你的服务器有用到nginx,同时后台执行较长时,后台就有可能会接收多次请求,前提是先确保前端没有发送多次请求. (因为nginx默认有个机制是当后台达到一定时间(时间根据nginx的配置)而又没有返回信息时,nginx就会尝试重新请求)
对此 有如下两种解决方案:
1. 确定自己项目不要用到nginx重发机制. 那么就直接 server_name 上面加上 proxy_next_upstream off; 这个就是整个域名都禁用了
2. 只想对某些url进行设置,那么可以参照如下设置.

nginx参考配置

server {
  #加在这为全局匹配
 ;
server_name www.域名.com;
root /home/wwwroot/项目名称;
index index.php index.html index.htm;

location / {
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}

# 这个地方是重点 包含thirdpayde的url都禁用重发机制
# 这个地方是重点 包含thirdpayde的url都禁用重发机制 ~ wthirdpayw 为正则, 可以将wthirdpayw替换你要匹配的路径
location ~ wthirdpayw {
proxy_next_upstream off;
}

location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/;
include fastcgi_params;
}

}
————————————————
原文链接:https://blog.csdn.net/weixin_37281289/java/article/details/88767714

原文地址:https://www.cnblogs.com/xzlive/p/13129990.html