通过nginx和proxy\u pass传递贝宝请求
我试图通过配置为代理的Nginx服务器将请求传递给paypalnvp沙盒Api() nginx配置是通过nginx和proxy\u pass传递贝宝请求,nginx,paypal,proxy,Nginx,Paypal,Proxy,我试图通过配置为代理的Nginx服务器将请求传递给paypalnvp沙盒Api() 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.pay
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;
}
}
没有代理的测试请求类似于
$ curl https://api-3t.sandbox.paypal.com/nvp
结果
ACK=Failure&L_ERRORCODE0=81002&L_SHORTMESSAGE0=Unspecified%20Method&L_LONGMESSAGE0=Method%20Specified%20is%20not%20Supported&L_SEVERITYCODE0=Error
使用代理
$ curl localhost/nvp
我没有得到答复,日志显示请求不正确:
127.0.0.1 - - [23/Feb/2016:08:28:50 -0500] "HEAD /nvp HTTP/1.1" 400 0 "-" "curl/7.29.0" "-"
我希望得到与直接请求相同的结果(ACK=Failure…
)
如果我对代理通行证使用不同的URL(比如谷歌),一切都会正常运行(当然,我会得到不同的响应)。在PayPal api或nginx文档中的搜索结束时,我没有得到任何结果
有人知道这种设置是否可行或如何修复吗
谢谢你的帮助
问候
丹尼斯终于找到了答案:我需要添加
proxy_http_version 1.1;
nginx按照默认1.0发送,但paypal需要1.1
我的请求的最低配置是
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;
}
}