Micronaut server and httpclient behind corporate proxy

拜拜、爱过 提交于 2019-12-13 04:11:35

问题


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


回答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.




回答2:


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



来源:https://stackoverflow.com/questions/55813538/micronaut-server-and-httpclient-behind-corporate-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!