curl -X 8888

为什么curl命令中加上 -X 8888 可以把后面的地址代理到Charles? 原理是什么

这是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.
  1. curl -x 和 curl -X get 是不一样的命令? 因为 curl -x get 就直接访问了百度
  2. curl 设置代理后, Charles是不是能监听到所有8888端口的请求?

1.是不一样 两个参数的两个功能

curl 设置代理的意思是把转发到127.0.0.1:8888这个host上,再把请求发送出去?


差不多吧 你可以把代理当成中间商~ :grimacing: :grimacing:

那Charles是不是可以理解为监听中间商, 截获请求?