Linux 如何通过本地代理允许 curl?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7474045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to allow curl via a local proxy?
提问by cwd
According the the Charles Proxy configuration page, you can manually set up a proxy if you use your localhost with port 8080.
根据Charles Proxy 配置页面,如果您使用带有端口 8080 的本地主机,则可以手动设置代理。
The syntax is curl --proxy localhost:8080 http://google.com/
语法是 curl --proxy localhost:8080 http://google.com/
However, this is not working for me. Here is my syntax and results - i'm also using the -v
option for debugging:
但是,这对我不起作用。这是我的语法和结果 - 我也在使用-v
调试选项:
curl -v --proxy localhost:8080 http://google.com/
* About to connect() to proxy localhost port 8080 (#0)
* Trying 127.0.0.1... Connection refused
* Trying ::1... Connection refused
* Trying fe80::1... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
I can connect to localhost:8080 in the web browser, and the results are logged in the proxy. However this is not working, the connecting is refused and nothing is logged.
我可以在网络浏览器中连接到 localhost:8080,并将结果记录在代理中。但是这不起作用,连接被拒绝并且没有记录任何内容。
So far I have also tried:
到目前为止,我还尝试过:
- executing this as root
- using 127.0.0.1 instead of localhost
- using wget instead of curl
- disabling the system firewall
What am I doing wrong? What else can I try?
我究竟做错了什么?我还能尝试什么?
采纳答案by Marc B
Connection refused would suggest that nothing is listening on port 8080. Charles has to be running (and listening on port 8080) for curl to be able to use it as a proxy. That or you've got a firewall actively blocking that port, preventing anything from connecting.
连接被拒绝意味着没有任何东西在侦听端口 8080。Charles 必须运行(并侦听端口 8080)才能使 curl 能够将其用作代理。那或者你有一个防火墙主动阻止那个端口,阻止任何东西连接。
回答by rrrhys
I had some success using port 8888:
curl http://www.google.com --proxy 127.0.0.1:8888
我使用端口 8888 取得了一些成功:
curl http://www.google.com --proxy 127.0.0.1:8888