[英]pass PayPal requests through nginx with proxy_pass
I'm trying to pass a request to the PayPal NVP Sandbox Api ( https://api-3t.sandbox.paypal.com/nvp ) through an Nginx server configured as a proxy. 我正在尝试通过配置为代理的Nginx服务器将请求传递给PayPal NVP沙箱Api( https://api-3t.sandbox.paypal.com/nvp )。
The nginx configuration is Nginx配置是
server {
listen 80;
server_name localhost;
error_log /var/log/nginx/error_pp.log debug;
location / {
#proxy_pass https://google.com:443; # works
proxy_pass https://api-3t.sandbox.paypal.com:443;
}
}
A test-request without the proxy is something like 没有代理的测试请求就像
$ curl https://api-3t.sandbox.paypal.com/nvp
with the result 结果
ACK=Failure&L_ERRORCODE0=81002&L_SHORTMESSAGE0=Unspecified%20Method&L_LONGMESSAGE0=Method%20Specified%20is%20not%20Supported&L_SEVERITYCODE0=Error
Using the proxy 使用代理
$ curl localhost/nvp
I get no answer and the logs show a bad request: 我没有答案,日志显示错误的请求:
127.0.0.1 - - [23/Feb/2016:08:28:50 -0500] "HEAD /nvp HTTP/1.1" 400 0 "-" "curl/7.29.0" "-"
I would have expected the same result as the direct request ( ACK=Failure...
). 我本来希望得到与直接请求相同的结果(
ACK=Failure...
)。
If I use a different URL for proxy_pass
(like google) everything works fine ( I get a different response, of course). 如果我对
proxy_pass
使用不同的URL(例如google),则一切正常(我得到的响应当然是不同的)。 A search in the PayPal api or the nginx docs ended without a result for me. 在PayPal api或nginx文档中的搜索对我而言没有结果。
Has anybody a clue if this setup is possible or how this can be fixed? 有没有人知道这种设置是否可行或如何解决?
Thanks for any help! 谢谢你的帮助!
Regards dennis 问候丹尼斯
Finally found the answer: I need to add 终于找到答案了:我需要添加
proxy_http_version 1.1;
nginx sends per default 1.0 but paypal requires 1.1. nginx默认发送1.0,但Paypal需要1.1。
The minimal configuration for my requests is 我的请求的最小配置是
server {
listen 80;
server_name localhost;
# PayPal:
ssl_protocols TLSv1.2;
proxy_http_version 1.1;
location / {
proxy_pass https://api-3t.sandbox.paypal.com:443;
proxy_cache_bypass 1;
proxy_no_cache 1;
proxy_read_timeout 60s;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.