乐闻世界logo
搜索文章和话题

How do I make curl ignore the proxy?

1个答案

1

When using the curl command-line tool, if you need curl to ignore system proxy settings, you can achieve this by setting environment variables or specifying directly in the command. There are two common methods:

Method 1: Using the --noproxy Command-Line Option

If you only want to ignore the proxy for a specific command, you can use the --noproxy option. For example, if you don't want to access example.com via a proxy, you can set it as:

bash
curl --noproxy "*" http://example.com

Here, * can be replaced with specific domain names or IP addresses. If set to *, no proxy is used for all addresses.

Method 2: Setting Environment Variables

If you want to ignore the proxy for the entire session, you can achieve this by setting environment variables.

For Unix-like systems, execute in the terminal:

bash
export no_proxy="*"

For Windows systems, execute in the command prompt:

cmd
set no_proxy=*

After this setup, all curl requests initiated through this terminal window will ignore system proxy settings.

Summary

Using the --noproxy option targets individual curl commands to ignore the proxy, suitable for temporary needs; setting the environment variable no_proxy is a more global approach, suitable for longer-term needs. Choose the method based on your specific requirements.

2024年8月13日 22:43 回复

你的答案