自动摘要
正在生成中……
为什么会有这样的需求呢?因为papay的ipn只支持一条url,而当多个网站都使用同一个paypal帐户收款,你就需要将ipn分发到多台服务器,这时就需要这种操作了,比如将 http://localhost/?stm_lms_check_ipn=1 的请求重放到 https://example.com 上。(有老外甚至为Paypal这个痛点做了付费服务?)
server {
..
server_name localhost;
error_page 418 = @stm_lms_check_ipn;
if ( $arg_stm_lms_check_ipn = "1" ) {
return 418;
}
location @stm_lms_check_ipn {
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
post_action @replay_ipn;
}
location @replay_ipn{
proxy_pass https://example.com;
}
...
参考链接:
https://serverfault.com/questions/413387/how-to-replicate-nginx-data-to-two-servers
https://serverfault.com/questions/811912/can-nginx-location-blocks-match-a-url-query-string