Marten Sytema
Marten Sytema

Reputation: 1926

Configure clojure http-kit to use a forward proxy

I have a little Clojure app that uses http-kit to send some http post requests to a server. I want to route the https POST request through a proxy P, ie. I want the traffic to go like App->Proxy->Server.

(This is because the target host X restricts access based on IP)

Is this possible?

Also the App runs on an ubuntu server, are there maybe system-level configurations possible to make http-kit use a proxy server? I prefer other processes to be unaffected though.

Upvotes: 1

Views: 1006

Answers (2)

Gestalti Lur
Gestalti Lur

Reputation: 31

http-clj now support proxy: https://github.com/dakrone/clj-http#proxies

For http-kit, according to the author's reply in this issue, the answer is NO.

But the good news is fewer weeks before it support basic HTTP proxy ( commit a207537 on http-kit ).

After all, it seems there is no way to set up a system wide proxy for JVM applications.

Upvotes: 1

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91534

http-kit is supposed to follow the standard method of configuring proxies in Java:

-Dhttp.proxyHost=proxyhostURL \
-Dhttp.proxyPort=proxyPortNumber \
-Dhttp.proxyUser=someUserName \
-Dhttp.proxyPassword=somePassword

which you can set in your lein profile or in the application server if you are using one.

Upvotes: 3

Related Questions