代理服务器上的cUrl通过代理返回403返回状态200,cUrl

时间:2016-08-12 18:44:46

标签: curl proxy

我目前正在尝试通过代理来卷曲网站。 我使用Squid设置代理服务器。 我的squid.conf配置是:

acl allowed_ip src xxx.xxx.xxx.xxx (ip of the other server)
http_access allow allowed_ip
http_access deny all

当我在我的代理服务器上ssh时,我可以这样做:

curl http://www.submarino.com.br -i

我得到:

HTTP/1.1 200 OK
Content-Type: text/html;charset=UTF-8
Server: Apache-Coyote/1.1
X-Powered-By: JSF/1.2
x-tid: CATALOGO-05ada7f1-ed40-4192-b487-47e658111844
Cache-Control: max-age=698
Expires: Fri, 12 Aug 2016 18:48:49 GMT
Date: Fri, 12 Aug 2016 18:37:11 GMT
Transfer-Encoding:  chunked
Connection: keep-alive
Connection: Transfer-Encoding
Set-Cookie: MobileOptOut=1; path=/; domain=submarino.com.br
Set-Cookie: b2wChannel=INTERNET; path=/; domain=submarino.com.br
Vary: Accept-Encoding, User-Agent

但是,如果我试图通过我的其他服务器,使用:

curl 'http://www.submarino.com.br' --proxy 128.199.209.72:3128 -v

我明白了:

* Rebuilt URL to: http://www.submarino.com.br/
* Hostname was NOT found in DNS cache
*   Trying xxx.xxx.xxx.xx...
* Connected to xxx.xxx.xxx.xx (xxx.xxx.xxx.xx) port xxxx (#0)
> GET http://www.submarino.com.br/ HTTP/1.1
> User-Agent: curl/7.35.0
> Host: www.submarino.com.br
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 403 Forbidden
* Server AkamaiGHost is not blacklisted
< Server: AkamaiGHost
< Mime-Version: 1.0
< Content-Type: text/html
< Content-Length: 274
< Expires: Fri, 12 Aug 2016 18:31:16 GMT
< Date: Fri, 12 Aug 2016 18:31:16 GMT
< Set-Cookie: MobileOptOut=1; path=/; domain=submarino.com.br
< Set-Cookie: b2wChannel=INTERNET; path=/; domain=submarino.com.br
< Vary: Accept-Encoding, User-Agent
< X-Cache: MISS from ubuntu-512mb-sgp1-01
< X-Cache-Lookup: MISS from ubuntu-512mb-sgp1-01:3128
< Via: 1.1 ubuntu-512mb-sgp1-01 (squid/3.5.12)
< Connection: keep-alive
< 
* Connection #0 to host ----------- left intact

从结果来看,我似乎是通过代理连接的。在没有代理的情况下卷曲时我得到相同的结果。任何人都可以对此有所了解吗?

更新

我在我的代理上设置了基本身份验证,但错误是相同的。我可以连接到代理,但curl在给定的URL(www.submarino.com.br)上失败。 其他网址工作正常。

我试图在我的localhost上使用相同的代理。

GET http://www.submarino.com.br/ HTTP/1.1
> Host: www.submarino.com.br
> Proxy-Authorization: Basic cHJvbW9jb246cHJvbW9jb25ieWdlbmV6emkyMDE2
> User-Agent: curl/7.47.0
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 200 OK

在我的服务器上

Proxy auth using Basic with user 'xxxxxx'
> GET http://www.submarino.com.br/ HTTP/1.1
> Proxy-Authorization: Basic cHJvbW9jb246cHJvbW9jb25ieWdlbmV6emkyMDE2
> User-Agent: curl/7.35.0
> Host: www.submarino.com.br
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
< HTTP/1.1 403 Forbidden

基本上,当我不代理卷曲请求时,他们的工作方式相同。

1 个答案:

答案 0 :(得分:0)

您的squid代理主机拒绝请求。您可能需要使用代理进行身份验证。