Emacs behind HTTP proxy
Asked Answered
I

4

44

Emacs is able to access the Internet with packages such as url.el or the W3 web browser.

Also, the Emacs Lisp Package Archive is heavily dependent on package url.el.

Now, how do I configure Emacs to use my HTTP proxy to connect to the Internet in general?

Bonus points for any help with ELPA behind a proxy.

Yes, I've had problems with HTTP proxies before.

Ierna answered 20/10, 2009 at 15:20 Comment(0)
C
55

For w3m, this setting has worked for me:

(setq url-proxy-services '(("no_proxy" . "work\\.com")
                           ("http" . "proxy.work.com:911")))
Couvade answered 20/10, 2009 at 15:56 Comment(7)
@Trey Jackson: What if the proxy requires authentication?Nancinancie
If you require authentication, Emacs (at least 23.x) will ask you for your username and password, provided you have url-proxy-services set.Ego
Is it possible to make Emacs use IE proxy settings?Tazza
@gm There's no package that I know of that does it.Couvade
@Tazza - see this question: #10050686Ola
Just confirmed Emacs 22 will prompt for credentials as well. Thank you @EgoStyria
I had to add another line identical to the "http" line for https, but otherwise this did the trick for me.Uitlander
P
27

I've got authorization working by:

(setq url-proxy-services
   '(("no_proxy" . "^\\(localhost\\|10\\..*\\|192\\.168\\..*\\)")
     ("http" . "proxy.com:8080")
     ("https" . "proxy.com:8080")))

(setq url-http-proxy-basic-auth-storage
    (list (list "proxy.com:8080"
                (cons "Input your LDAP UID !"
                      (base64-encode-string "LOGIN:PASSWORD")))))

Works for Emacs 24.3. It is based on non-public API tricks, so might not work in another Emacs versions...

Phelloderm answered 9/9, 2013 at 11:24 Comment(3)
legend! btw this did not work for emacs 26 on windows, but was fine for 25.3Planetstruck
this worked for me (emacs 25.1.1 mingw from the gnu mirrors). If you're still playing SO -- I believe you want "10\..*" for the local host, you'll match anything that starts 10 with what you got there.Strickle
@LevinMagruder Updated!Phelloderm
A
14

Emacs populates the url-proxy-services variable from the http_proxy, https_proxy and no_proxy environment variables if they are set.

Allelomorph answered 14/7, 2016 at 23:40 Comment(2)
This is totally the way to goTadtada
Yes well, it doesn't work in my environment. I think they have some Bluecoat ssl cert also. How is that dealt with?Prau
S
5

This is a bit old, but I had issues connecting as well. One thing I needed to do is add my certificate to the the gnutls-trustfiles in order to connect.

(with-eval-after-load 'gnutls
    (add-to-list 'gnutls-trustfiles "path/to/cert.crt"))
(setq url-proxy-services
   '(("no_proxy" . "^\\(localhost\\|10\\..*\\|192\\.168\\..*\\)")
     ("http" . "proxy.com:8080")
     ("https" . "proxy.com:8080")))
Subprincipal answered 31/3, 2020 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.