Micronaut server and httpclient behind corporate proxy
Asked Answered
S

2

1

I'm running a micronaut microservice on a Win 7.

My GET Request looks like : http://localhost:8080/maps/myreq.

The controller use a httpclient to send request to an external webseite : image.maps.api.here.com

When running without proxy, all went fine and the response is ok (an image).

But when running behind the proxy, connection timed out. Proxy works fine for any other applications or browser.

How to set micronaut server behind proxy to properly root requests?

edit : when sending a request, the netty server respond with an error : unable to connect to image.maps.api.here.com:xx.xx.xx.xx:xxxx where xx.xx.xx.xx:xxxx is the proxy

Sleepyhead answered 23/4, 2019 at 14:30 Comment(0)
T
1

How to set micronaut server behind proxy to properly root requests?

You can set the https.proxyHost, https.proxyPort, http.proxyUser and http.proxyPassword system properties. A common place to do that is in the MN_OPTS environment variable. For example, you could set MN_OPTS to have a value like "-Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3128 -Dhttp.proxyUser=test -Dhttp.proxyPassword=test".

See https://docs.micronaut.io/1.1.0/guide/index.html#proxy for more info.

I hope that helps.

Toxicosis answered 23/4, 2019 at 14:44 Comment(6)
Thx. But I'm on Windows and the documentation with "Environment Variables" is a bit unfinished. It is the same if i want to use the system proxy settings?Sleepyhead
I am not sure what is unfinished but if you set those system properties in the MN_OPTS environment variable, I expect Micronaut to find and use them.Toxicosis
As the docs say... "For Windows systems the environment variable can be configured under My Computer/Advanced/Environment Variables".Toxicosis
system variables with name: MN_OPTS with value: -Dhttps.proxyHost=xx.xx.xx.xx -Dhttps.proxyPort=xxxx doesnt help and user variables with name: https.proxyHost with value: xx.xx.xx.xx and another with name: https.proxyport with value=xxxx neither.Sleepyhead
They appear to work here. If they don't' work for you please file a bug report at github.com/micronaut-projects/micronaut-core/issues and we can investigate. Sorry for the trouble.Toxicosis
They all work here too (Windows10). Make sure you type the proper address! in my case, the IT team told me the proxy host address in the compnay is 193.120.2.1 but you should just use the IP address "-Dhttps.proxyHost=193.120.2.1 "Cullis
S
0

I fixed the problem with settings the proxy for the CLI but also by setting the proxy in the application.yml like here : https://github.com/micronaut-projects/micronaut-core/issues/1611

Sleepyhead answered 15/5, 2019 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.