-
Notifications
You must be signed in to change notification settings - Fork 626
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
Replace localhost in proxy settings with the gateway address #351
Conversation
pkg/limayaml/default.yaml
Outdated
# the VM, so it stays routable. Use of the process environment can be disabled by setting | ||
# useProcessProxies to false. | ||
# Default: true | ||
useProcessProxies: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"replaceLocalhostProxies" might be more descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. If this option is false
, then Lima will ignore the process environment. If it is true
, then the process environment variables will override the proxy settings.
Lima will always replace "localhost" with the gateway address in proxy values from the environment, so this is not really what you control with this setting.
Now that I write this, I wonder if we should do the replacement in a final pass at the end, so proxys from the system settings are also processed. Except I wouldn't want to modify settings from lima.yaml
, as those are obviously meant to be relative to the VM itself. So maybe the current PR implementation is good enough?
I don't really see any point in making the substitution configurable, as the variables will simply not work inside the VM otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All that being said, I would welcome a better name than useProcessProxies
, which is hard to understand unless you read the whole paragraph above. The problem is that "host" refers also to the system settings, so I wanted a term that just refers to the environment variables of the limactl process when it is starting the VM...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about propagateProxyEnv
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @jandubois @AkihiroSuda thanks for a quick fix, just a small comment as I did give a test to the new version and looks like it ("sort of") works :)
By "sort of" I mean that in the initial limactl start
the http(s)_proxy
are propagated and replace with the GW IP.
The downside is the new environment vars are only available after another reboot l limactl stop/start
since they are written in the /etc/environment
file
- Initial start
...
INFO[0000] [hostagent] Replacing "http_proxy" value "http://localhost:3128" with "http://192.168.5.2:3128"
INFO[0000] [hostagent] Replacing "https_proxy" value "http://localhost:3128" with "http://192.168.5.2:3128"
...
lima
printenv | grep https*_proxy
- Restart
printenv | grep https*_proxy
https_proxy=http://192.168.5.2:3128
http_proxy=http://192.168.5.2:3128
Is maybe a way to inject that in a /etc/profile
that is read after the initial login? so we can avoid extra provisioning scripts to reload the /etc/environment
on user login, or if there is a better way for this, let me know!
Lima uses process environment settings to override system proxy settings, and settings from the `env` key in lima.yaml. This does not work when the proxy is running on a localhost address, so this commit replaces localhost with the slirp gateway address. The new `useProcessProxies` setting can also be used to disable using the process environment variables to override proxy settings completely. Signed-off-by: Jan Dubois <[email protected]>
1d83b85
to
b78119b
Compare
Lima uses process environment settings to override system proxy settings, and settings from the
env
key in lima.yaml.This does not work when the proxy is running on a localhost address, so this commit replaces localhost with the slirp gateway address.
The new
useProcessProxies
setting can also be used to disable using the process environment variables to override proxy settings completely.Motivation: rancher-sandbox/rancher-desktop#431 (comment)