为什么curl命令中加上 -X 127.0.0.1 8888 可以把后面的地址代理到Charles? 原理是什么
因为curl命令的-x参数就是用来设置代理的
https://curl.haxx.se/docs/manpage.html
这是curl命令的介绍,你也可以使用命令man curl看到
其中提到了
-x, --proxy [protocol://]host[:port]
Use the specified proxy.
The proxy string can be specified with a protocol:// prefix. No protocol specified or http:// will be treated as HTTP proxy. Use socks4://, socks4a://, socks5:// or socks5h:// to request a specific SOCKS version to be used. (The protocol support was added in curl 7.21.7)
HTTPS proxy support via https:// protocol prefix was added in 7.52.0 for OpenSSL, GnuTLS and NSS.
Unrecognized and unsupported proxy protocols cause an error since 7.52.0. Prior versions may ignore the protocol and use http:// instead.
If the port number is not specified in the proxy string, it is assumed to be 1080.
This option overrides existing environment variables that set the proxy to use. If there's an environment variable setting a proxy, you can set proxy to "" to override it.
All operations that are performed over an HTTP proxy will transparently be converted to HTTP. It means that certain protocol specific operations might not be available. This is not the case if you can tunnel through the proxy, as one with the -p, --proxytunnel option.
User and password that might be provided in the proxy string are URL decoded by curl. This allows you to pass in special characters such as @ by using %40 or pass in a colon with %3a.
The proxy host can be specified the exact same way as the proxy environment variables, including the protocol prefix (http://) and the embedded user + password.
If this option is used several times, the last one will be used.
- curl -x 和 curl -X get 是不一样的命令? 因为 curl -x get http://www.baidu.com 就直接访问了百度
- curl 设置代理后, Charles是不是能监听到所有8888端口的请求?
1.是不一样 两个参数的两个功能
2.curl设置代理只是针对curl命令本身,charles能监听到什么要看charles的设置和有什么工具将代理设置为charles的监听地址了。curl命令本身跟charles并没有任何关系
curl 设置代理的意思是把http://www.baidu.com转发到127.0.0.1:8888这个host上, 127.0.0.1:8888再把http://www.baidu.com请求发送出去?
设置代理本身的含义有推荐的文档或视频看吗?
差不多吧 你可以把代理当成中间商~
那Charles是不是可以理解为监听中间商, 截获请求?