Linux curl post请求和错误417,但sudo成功?

我的服务部署在docker中,暴露的nginx端口是18082;服务端口是38087,我试了两次。

而我使用命令

curl -i -X POST -H'content-type:text / json'-d @ post.json \ http://127.0.0.1:18082/youtu/openliveapi/livedetectfour

返回417

HTTP/1.1 417 Expectation failed Server: squid/2.7.STABLE9 Date: Tue, 15 Aug 2017 11:57:04 GMT Content-Type: text/html Content-Length: 1436 X-Squid-Error: ERR_INVALID_REQ 0 X-Cache: MISS from SK-SQUIDDEV-118 X-Cache-Lookup: NONE from SK-SQUIDDEV-118:8080 Connection: close 

但是当我在前面添加sudo时,它会返回成功。 HTTP / 1.1 100继续HTTP / 1.1 200 OK服务器:openresty / 1.9.15.1

我真的在search并知道curl超过1024字节时,它会先发送

预计100-continue.if服务器不支持该请求,则会返回417错误。

那么怎么可以sudo succsess呢,也许这跟nginx机制有关,我不太熟悉。谢谢。

由于您在公司设置中使用代理,并且代理可能会插入到用户的bashconfiguration文件中。 你可以做3件事

更新〜/ .bash_profile或〜/ .bashrc

从你的个人资料中删除代理,你将不需要代理

取消设置variables

在调用之前,您可以取消设置variables

 unset http_proxy unset https_proxy curl -i -X POST -H 'content-type: text/json' -d @post.json \ http://127.0.0.1:18082/youtu/openliveapi/livedetectfour 

为呼叫清空variables

您可以为那个curl调用设置variables

 http_proxy= https_proxy= curl -i -X POST -H 'content-type: text/json' -d @post.json \ http://127.0.0.1:18082/youtu/openliveapi/livedetectfour