millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 123 forks source link

proxy settings are ignored #802

Closed sam-s closed 2 years ago

sam-s commented 3 years ago

I need to use a proxy only for some specific URLs, so I do:

(defun sds-url-proxy-locator (_urlobj host)
  "Use bastion for the emr cluster (amazon).
https://emacs.stackexchange.com/q/66422/795"
  (cond ((string-search ".ec2.internal" host)
         "PROXY ip-10-0-37-237.ec2.internal:8081")
        (t "DIRECT")))
(setq url-proxy-locator 'sds-url-proxy-locator)

However, when I do ein:notebooklist-login on "https://ip-10-0-37-237.ec2.internal:9443/user/jovyan/notebooks/", my function sds-url-proxy-locator is not called, presumably because ein calls curl directly, and the connection fails with

ein: [info] ein:jupyter-process-lines: jupyter exited with status 1
[error] request--callback: peculiar error
ein: [error] Login to https://ip-10-0-37-237.ec2.internal:9443/user/jovyan/tree failed, error-thrown (error . exited abnormally with code 6 ), raw-header 

I don't think I can set ACCESS_proxy in such a way that it will point to the proxy only for some specific URLs.

It would be nice if ein could take care of it just like FoxyProxy takes care of it for Chrome: call url-find-proxy-for-url and set ACCESS_proxy for curl appropriately.

dickmao commented 2 years ago

I looked at url-proxy.el and it's like 100 lines of elisp that for your purposes could be reduced down to:

if url contains .ec2.internal, then use ip-10-0-37-237.ec2.internal:8081

so I decided against doing anything about it.