Skip to content

Commit

Permalink
Merge pull request #2038 from ogayot/proxy-doc
Browse files Browse the repository at this point in the history
Add example for `proxy:` autoinstall directive.
  • Loading branch information
ogayot authored Jul 26, 2024
2 parents adf1102 + 1c6e164 commit 32e3ff0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion doc/reference/autoinstall-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,14 @@ proxy
* **default:** no proxy
* **can be interactive:** true

The proxy to configure both during installation and for ``apt`` and ``snapd`` in the target system.
The proxy to configure both during installation and for ``apt`` and ``snapd`` in the target system. This setting is currently not honoured when running the geoip lookup.

Example:

.. code-block:: yaml
autoinstall:
proxy: http://172.16.90.1:3128
.. _ai-apt:

Expand Down
6 changes: 6 additions & 0 deletions subiquity/server/geoip.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class HTTPGeoIPStrategy(GeoIPStrategy):
async def get_response(self) -> str:
url = "https://geoip.ubuntu.com/lookup"
async with aiohttp.ClientSession() as session:
# We probably want to honor proxy settings here; using
# session.get(url, proxy=...) so that we can perform a successful
# geoip lookup in a walled garden. Bear in mind that it would
# result in a geoip lookup of the proxy itself (the proxy initiates
# the connection to the geoip service) but in most cases this is
# what we want.
async with session.get(url) as response:
response.raise_for_status()
return await response.text()
Expand Down
4 changes: 4 additions & 0 deletions subiquity/server/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ async def fetch_keys_for_id(self, user_id: str) -> List[str]:
cmd = ("ssh-import-id", "--output", "-", "--", user_id)
env = None
if self.app.base_model.proxy.proxy:
# This is probably not needed since ProxyController.POST and
# ProxyController.start both set the http_proxy / https_proxy
# variables. This was probably needed when SSH key import was done
# by the client though.
env = os.environ.copy()
env["https_proxy"] = self.app.base_model.proxy.proxy

Expand Down

0 comments on commit 32e3ff0

Please sign in to comment.