Skip to content

AWS CLI not working behind proxy

0

Issue: I’m trying to get aws cli working through a proxy on a Windows or linux guest VM but not having any luck.

Note: all my VMs are configured with my organization proxy, these allows us to connect successfully to Internet via https

requirement: ( testing Aws cloud ) Configure Aws CLI on a windows and Linux guest vm which is connected to Internet via proxy-server. have set the PROXY address as per the AWS documentation (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-proxy.html), but still getting error "Failed to connect to proxy URL https:\IPADDRESS:PORTnumber"

note: I am able to connect to Azure cloud using azure cli from the same VMs.

How do i connect to aws cli using the proxy ?

Regards Nithin

asked 4 years ago5.3K views

1 Answer
0

Hello Nithin, I understand you're having trouble configuring AWS CLI to work through a proxy on both Windows and Linux guest VMs. Let's address this issue step by step. Remember to always follow security best practices when configuring your AWS CLI and handling credentials. Regularly rotate your access keys and use the principle of least privilege when assigning permissions. Let's break this down.

  1. Verify proxy configuration: Ensure that the proxy settings are correctly configured in your environment variables. For Windows, you can set these in the System Properties or use the following commands in PowerShell:

    $env:HTTP_PROXY="http://your_proxy:your_port" $env:HTTPS_PROXY="http://your_proxy:your_port"

  2. For Linux, you can set these in your shell profile or use:

    export HTTP_PROXY="http://your_proxy:your_port" export HTTPS_PROXY="http://your_proxy:your_port"

  3. Check AWS CLI configuration: Ensure that your AWS CLI is properly configured with your credentials. Run:

    aws configure

    Enter your AWS Access Key ID, Secret Access Key, default region, and output format.

    Test the connection: Try running a simple AWS CLI command to test the connection, such as:

    aws s3 ls

    Verify proxy authentication: If your proxy requires authentication, include the username and password in the proxy URL:

    http://username:password@your_proxy:your_port

  4. Check firewall settings: Ensure that your firewall is not blocking the AWS CLI from accessing the internet through the proxy.

    Use the --no-verify-ssl option: If you're still encountering SSL verification issues, you can try:

    aws s3 ls --no-verify-ssl

    Note: This is not recommended for production use due to security implications.

  5. Check proxy logs: If possible, check the proxy server logs to see if there are any errors or blocked requests.

    Use AWS CLI proxy options: You can also specify the proxy directly in the AWS CLI command:

    aws s3 ls --proxy http://your_proxy:your_port

    Verify no_proxy settings: Ensure that the no_proxy environment variable doesn't include AWS endpoints.

If you're still encountering issues after trying the above steps, I recommend:

  1. Double-check that the proxy settings are correct and that the proxy server is functioning properly.
  2. Verify that your AWS credentials are valid and have the necessary permissions.
  3. Try using the AWS CLI from a non-proxied network to isolate whether the issue is specific to the proxy configuration.

If you are still not able to resolve this issue, I would recommend reaching out to AWS Support for further assistance, as they can provide more tailored troubleshooting based on your specific account and network configuration.

Additional Resources:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2config-proxy.html

https://docs.aws.amazon.com/iot/latest/developerguide/configure-local-proxy-web-proxy.html

https://repost.aws/questions/QUAAQQbjDUSGa5wRjNftXVnA/vpn-or-proxy-or-secure-connection

Hopefully this helps provide a resolution.

Best of luck and thank you for using AWS!

Brian

AWS

answered 2 years ago

  • Hello,

    we have a similar issue where the CLI is not working behind our customer's Production proxy but it is working when behind the Pre-production proxy.

    After a thorough investigation, the Wireshark tracing seems to suggest that the AWS CLI is using HTTP 1.0 and HTTP 1.0 is blocked by the production proxy.

    Is there a way to tell the AWS CLI to use HTTP 1.1 instead? How can we justify to the customer that HTTP 1.0 is preferred?

    Thanks Christian

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.