If you live in a country that prohibit from access the world wide web. You may want to use proxy server to access the world wide web. Recently, I built a Rust
project, but it always showed me a network error. So I google the question and finally found the answer. Here is how to configure the cargo
to use a proxy:
- open the
~/.cargo/config
file, if the file is not exist, ceate the file namedconfig
.
[http]
proxy = "socks5h://127.0.0.1:1084" # HTTP proxy to use for HTTP requests (defaults to none)
# in libcurl format, e.g., "socks5h://host:port"
timeout = 30 # Timeout for each HTTP request, in seconds
#cainfo = "cert.pem" # Path to Certificate Authority (CA) bundle (optional)
check-revoke = false # Indicates whether SSL certs are checked for revocation
#low-speed-limit = 5 # Lower threshold for bytes/sec (10 = default, 0 = disabled)
multiplexing = false # whether or not to use HTTP/2 multiplexing where possible
That's all you have to do and feel free to build the Rust
project.