自从 TradingView 开放他们的 webhook 支持以来,我一直在努力弄清楚为什么我的服务器没有收到任何信号。到目前为止,我已经完成了以下工作:
您可以在此处实时查看信号:http://webhook.site/#!/48e29a5b-d266-4021-8b96-0039371b3643/2005d010-e3ae-4077-8808-af34491f5a4d/
但是在交付过程中的某个地方显然出了问题,因为在 nginx 日志和 unix 日志中甚至没有任何请求的痕迹。这绝对不是防火墙或 CORS 问题,或者我在使用工具进行复制时也会遇到同样的问题,对吧?有谁能帮我破解这个案子吗?
这是我的 nginx 配置:
server {
listen 80;
server_name lunarlabs.org;
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name lunarlabs.org;
ssl_certificate /etc/letsencrypt/live/***.org/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/***.org/privkey.pem;
# ...
access_log /var/log/nginx.log;
error_log /var/log/nginxerror.log;
root /var/www/html/public;
index index.php;
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,X-Forwarded-For,content-length';
include proxy_params;
proxy_pass http://unix:/home/tvhook/***;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
可以通过 https://lunarlabs.org/webhook 访问我设置的演示 webhook 服务器-- 任何 JSON 格式的 POST 数据都应该返回 200。但 TradingView 的信号似乎真的不喜欢我的服务器,或者我的服务器真的不喜欢他们的请求。
最佳答案
我有同样的问题。
Tradingview 支持报告错误:“x509:证书由未知机构签名”。
但是 curl 请求对我来说效果很好。
我正在使用 Comodo SSL 证书,结果发现我没有在 nginx 中设置“链证书”。设置它并重新启动 nginx 有帮助。电视形式的 Webhook 现在工作正常。
关于ubuntu - TradingView WebHook API 不起作用,是什么阻止了 POST 请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57648719/