Mystery0の小站

Mystery0の小站

cloud-torrent使用nginx反向代理后/sync接口问题记录

2022-07-15
cloud-torrent使用nginx反向代理后/sync接口问题记录

问题现象

图片-1657864688254

打开控制台发现是/sync接口没有响应,nginx上面查看日志,显示连接拒绝

2022/07/14 23:23:03 [error] 475123#0: *2447438 connect() failed (111: Connection refused) while connecting to upstream, client: 1.1.1.1, server: xxx.xxx.app, request: "GET /sync?v=1987667&id=10bb0722 HTTP/2.0", upstream: "http://127.0.0.1:3000/sync?v=1987667&id=10bb0722", host: "xxx.xxx.app", referrer: "https://xxx.xxx.app/"

解决方案

往nginx反向代理块中添加以下路由

location /sync {
    proxy_set_header Cache-Control: no-cache;
    chunked_transfer_encoding off; 
    proxy_cache off;
    proxy_buffering off;
    proxy_set_header Connection keep-alive;
    proxy_pass http://127.0.0.1:3000/sync;
}

初步怀疑是走了缓存导致的,添加之后就可以打开了

图片-1657864876303