Add support for proxies

Bug #1533899 reported by Carlos Alberto Armenta Castro
52
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Snap Layer
Fix Released
Wishlist
Stuart Bishop
Snapcraft
Invalid
Undecided
Unassigned
Snappy
Fix Released
Wishlist
Unassigned
cloud-init
Expired
Undecided
Unassigned
snapweb
Invalid
Undecided
Unassigned
snapd (Ubuntu)
Fix Released
Medium
Unassigned
Trusty
Fix Released
Undecided
Unassigned

Bug Description

Actually ubuntu-core do not support proxy configuration, that is a problem for example for run correctly "webdm": "Error: Get https://search.apps.ubuntu.com/api/v1/search?........ read: connection refused".
I can configure proxy with export http_proxy="http://x.x.x.x.x" but only affects the session not the wide system.

Related branches

Changed in snapcraft:
status: New → Invalid
Revision history for this message
Michael Vogt (mvo) wrote :

This is indeed true and more true with the move to snapd. In order to create a proxy config you need to do something like:
```
    sudo mkdir -p /etc/systemd/system/snapd.service.d/
    sudo cat <<EOF | sudo tee -a /etc/systemd/system/snapd.service.d/proxy.conf
[Service]
Environment=http_proxy=$http_proxy
Environment=https_proxy=$http_proxy
EOF
    sudo systemctl daemon-reload
```

Changed in snappy:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Steven Wilkin (stevenwilkin) wrote :

WebDM is now fully a client of the snapd REST API hence this issue doesn't affect it.

Changed in webdm:
status: New → Invalid
Revision history for this message
Stuart Bishop (stub) wrote :

Added cloud init, as it should be able to provision machines with snappy configured correctly.

Can we get a snap specific snap_proxy, rather than reusing http_proxy which affects everything on the system (apt, userland, etc.).

Jacek Nykis (jacekn)
tags: added: canonical-is
Stuart Bishop (stub)
Changed in layer-snap:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Stuart Bishop (stub) wrote :

Snap layer is using @mvo's approach above.

Changed in layer-snap:
assignee: nobody → Stuart Bishop (stub)
status: Triaged → Fix Released
Revision history for this message
Barry Price (barryprice) wrote :

n.b. the fix in comment 1 works for 'snap install', but not 'snap download', which seems to ignore any http_proxy or https_proxy values.

Revision history for this message
Barry Price (barryprice) wrote :

Oh, and you also need to restart snapd.service itself after running systemctl daemon-reload.

Revision history for this message
John Lenton (chipaca) wrote :

@barryprice, if you add the proxy values to /etc/environment (which many guis already do for you), then both snapd and snap will pick it up (once restarted appropriately).

Revision history for this message
Barry Price (barryprice) wrote :

chipaca: That's only useful if you want every application on the system to use a proxy for all HTTP/S traffic.

It should be simpler, IMHO, to configure only snapd/snap to use a proxy for Snap Store traffic only.

Revision history for this message
John Lenton (chipaca) wrote :

Agreed.

Going back a bit, you mention that you can't make `snap download` respect the proxy environment variables. I've just confirmed that it does, so what exactly are you trying?

http_proxy=https://localhost:99/ snap download foo
Fetching snap "foo"
error: cannot find snap "foo": Get https://search.apps.ubuntu.com/api/v1/snaps/details/foo: http: error connecting to proxy https://localhost:99/: dial tcp 127.0.0.1:99: getsockopt: connection refused

Revision history for this message
Stuart Bishop (stub) wrote :

Setting the environment in snapd.service.d per comment #1 does not work for snap download, but the different workaround in comment #9 should work fine.

Revision history for this message
Stuart Bishop (stub) wrote :

Does anyone have a work around for trusty? We are unable to deploy snaps on our internal trusty hosts at the moment.

Revision history for this message
Haw Loeung (hloeung) wrote :

mvo's solution in #1 does indeed work.

Michael Vogt (mvo)
Changed in snapd (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Stuart Bishop (stub) wrote :

Support for setting proxies seems to have landed, but is not yet documented. 'sudo snap get core proxy'

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Re: [Bug 1533899] Re: Add support for proxies

Unless something has changed that only does anything on an Ubuntu core
system (where it edits /etc/environment for you)

On Tue, 21 Aug 2018, 17:07 Stuart Bishop, <email address hidden>
wrote:

> Support for setting proxies seems to have landed, but is not yet
> documented. 'sudo snap get core proxy'
>
> --
> You received this bug notification because you are a member of Canonical
> Cloudware, which is subscribed to cloud-init.
> Matching subscriptions: cloud-init bugs
> https://bugs.launchpad.net/bugs/1533899
>
> Title:
> Add support for proxies
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/cloud-init/+bug/1533899/+subscriptions
>

Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

This is supposed to work indeed, even outside of Ubuntu Core.

It's also documented:

https://snapdocs.labix.org/configuration-options/87

(this will go into snapcraft.io/docs soon)

I'm going to close this issue for now. Please reopen if I'm missing something.

Changed in snapd (Ubuntu):
status: Triaged → Fix Released
Changed in snapd (Ubuntu Trusty):
status: New → Fix Released
Changed in snappy:
status: Triaged → Fix Released
Revision history for this message
Michael Vogt (mvo) wrote :

On classic systems snapd will honor the system proxy settings via http_proxy (and friends). However it does not (yet) respect the internal settings. The following PR changes this: https://github.com/snapcore/snapd/pull/5699

Revision history for this message
Dan Watkins (oddbloke) wrote :

It's not totally clear to me what the required cloud-init changes here are, please feel free to move the task back to New with some clarification.

Changed in cloud-init:
status: New → Incomplete
Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.