Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP/HTTPS proxy for connections #338

Closed
asieira opened this issue Nov 2, 2015 · 25 comments
Closed

HTTP/HTTPS proxy for connections #338

asieira opened this issue Nov 2, 2015 · 25 comments
Labels
feature-request This issue requests a feature. proxy

Comments

@asieira
Copy link

asieira commented Nov 2, 2015

The old boto library had arguments proxy, proxy_port, proxy_user and proxy_pass to allow connections to the API endpoints to go through a proxy.

What is the boto3 equivalent way of programmatically setting the proxy parameters (i.e., not using the configuration file)?

@aki263
Copy link

aki263 commented Nov 3, 2015

I have same issue. I cant event set proxy with global conf file placed in /etc/boto.cfg .

@kyleknap
Copy link
Contributor

kyleknap commented Nov 3, 2015

So boto3 does not require the global config to set proxies. All you need to do is set the general https_proxy environment variable and requests/urllib3 should use the value stored in that environment variable. So something like:

export https_proxy=https://username:password@hostname:port

Let me know if this helps.

@kyleknap kyleknap added closing-soon This issue will automatically close in 4 days unless further comments are made. proxy labels Nov 3, 2015
@asieira
Copy link
Author

asieira commented Nov 10, 2015

I think this is a poor replacement. I might want to override what's in the environment variable without changing it and causing side effects on other libraries or portions of a larger program.

Also, this environment variable is a very *nix-centric standard, which IMHO is poor form for a portable library such as boto3.

I would strongly suggest that a way for this to be specified explicitly is available when a boto3 connection is opened.

@themanifold
Copy link

I would agree with the above comment. I think it would be better if the proxies could be set via the config file, and better still, via the interface outlined in #325

@jamesls
Copy link
Member

jamesls commented Nov 16, 2015

Marking as a feature request.

@jamesls jamesls added feature-request This issue requests a feature. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Nov 16, 2015
@bobveznat
Copy link

We also require this functionality. We need a clean way of indicating that boto uses the proxy while other services on the same machine do not. Effectively it boils down to "local" services don't require a proxy but "internet" services do.

We're actually going to port our greenfield boto3 code back to boto2 now.

@themanifold
Copy link

Has there been any progress on this? We require this for our organisation too.

@themanifold
Copy link

This is just another ping to find out what is going on with this feature...

@alborworld
Copy link

alborworld commented Jun 9, 2016

Same thing here. We need this functionality and currently we're backporting boto3 code to boto2 because of this. Please implement this feature.

@mjs2180
Copy link

mjs2180 commented Jun 10, 2016

Same request but for making use of boto3 running on AWS Lambda in a VPC to connect via a corporate proxy. Need to be able to set a proxy in the code as setting the environment variables has to be done before you instantiate the AWS clients. This means I can't pass them as parameters and they have to be hardcoded.

@marekq
Copy link

marekq commented Jun 17, 2016

I have the same issue from an internal network, would love to see proper support for proxies!

@feifangit
Copy link

any update?

@MikeMcMahon
Copy link

any movement on this issue? Seems silly that we'd lose this functionality, it's kind of a pain when running boto3 bundled into something like apache. so it's not really running with the standard environment, we have to utilize apache libs to pass in environment variables.

@jamesls
Copy link
Member

jamesls commented Sep 2, 2016

So would adding this as an option to the Config object proposed here be sufficient? Something like:

ec2 = boto3.client('ec2', config=Config(proxy='http...'))

@MikeMcMahon
Copy link

@jamesls A better solution than current, but still preferred would be having the prior boto functionality of being able to specify it via a configuration file, especially in terms of credentials storage.

@jamesls
Copy link
Member

jamesls commented Sep 2, 2016

Ok, so to capture both ideas, you could ideally do either:

ec2 = boto3.client('ec2', config=Config(proxy='http....'))

Or you could do:

$ cat ~/.aws/config
[default]
proxy=http://...

$ python
>>> import boto3
>>> boto3.client('ec2') # Would use the proxy settings.

@tmylk
Copy link

tmylk commented Oct 5, 2016

May I ask if this is on the roadmap?
The lack of this feature stops us from migrating to boto3 from boto2 in the smart_open package.

@skortchmark9
Copy link

This is important for our use case also. Specifically, setting the http proxy interferes with pip installs from our pip index.

@alborworld
Copy link

alborworld commented Jan 6, 2017

Hi, please have a look at the following solution.

https://aws.amazon.com/blogs/security/how-to-add-dns-filtering-to-your-nat-instance-with-squid/

Apparently this would free us from the need of setting the HTTP proxy in every instance of the private subnet. What do you think?

@asieira
Copy link
Author

asieira commented Jan 6, 2017

This article describes one particular way of implementing a transparent proxy. However, some of us have to write Python programs using boto that run on environments we don't control and where using an explicit proxy is a requirement.

If you do control your network environment and can use a transparent proxy as a workaround for the lack of explicit proxy control in boto3, then by all means do so. But IMHO the need to allow this configuration in boto3 still remains as important as ever.

@FlorianHeigl
Copy link

FlorianHeigl commented Jan 6, 2017

Why is a regression marked as a feature anyway?

@thewb
Copy link

thewb commented Mar 7, 2017

So you guys broke functionality and now consider fixing it, or reverting actually, a feature request? Y'all need Jesus.

timuralp pushed a commit to timuralp/botocore that referenced this issue Jun 22, 2017
Allows setting the proxy servers to be used through the Config object
when creating the client.

Refs: boto/boto3#338
@timuralp
Copy link

timuralp commented Jun 22, 2017

Submitted a PR (boto/botocore#1228) in botocore to plumb the proxies option from Config to the Endpoint. Happy to iterate on it if this is desirable and if there is some feedback on the patch.

@opsroller
Copy link

Hmmm, export no_proxy="*.someservice.amazonaws.com"

@JordonPhillips
Copy link
Contributor

Closing since @timuralp 's PR was merged. Feel free to open another issue if you have additional problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue requests a feature. proxy
Projects
None yet
Development

No branches or pull requests