# Intranet solution Java agent send metric to cloud apm server via proxy server

**URL:** <https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153>\
**Category:** APM\
**Tags:** java\
**Created:** [July 12, 2019, 7:42am UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153 "2019-07-12T07:42:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wayne\_Shen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_shen/32/49847_2.png) [@Wayne\_Shen](https://discuss.elastic.co/u/Wayne_Shen)\
**Post date:** [July 12, 2019, 7:42am UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/1 "2019-07-12T07:42:18Z")

</div>

Hello,

Is it possible to configure the java agent to send the metrics through a proxy server?

My service is deployed in an intranet server, it connect to apm server (deployed in cloud) though a proxy server.

ELK version: 7.2.0  
Java Agent: 1.7.0

After I read the documentation I am not able find any settings related to proxy server.

elasticapm.properties  
proxy\_server?  
proxy\_port?

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 12, 2019, 9:04am UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/2 "2019-07-12T09:04:28Z")

</div>

Hi,

there are no dedicated APM agent settings for using a proxy but as the agent is using `HttpUrlConnection`, you can just use the Java system properties `http.proxyHost` and `http.proxyPort`.

See also [https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html](https://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html) for more information.

However, that sets the proxy JVM-wide. Is that what you want?

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![digitalron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/digitalron/32/38224_2.png) [@digitalron](https://discuss.elastic.co/u/digitalron)\
**Post date:** [July 12, 2019, 1:28pm UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/3 "2019-07-12T13:28:22Z")

</div>

You mean a reverse proxy like HAProxy?

That's how my set up is, and is necessary if you want to load balance multiple APM Servers. But even a single backend to the proxy works as I have that simplke config for quick testing

APM Agent --\> HAProxy --\> APM Server --\> Elasticsearch

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 12, 2019, 5:51pm UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/4 "2019-07-12T17:51:11Z")

</div>

> [@digitalron](#):
>
> You mean a reverse proxy like HAProxy?

I think the kind of proxy @Wayne_Shen is talking about is one which proxies requests from a DMZ to the outside world and used to restrict access to the internet.

> [@digitalron](#):
>
> That's how my set up is, and is necessary if you want to load balance multiple APM Servers.

Note that you can configure multiple URLs in `server_urls` which allows load balancing without a dedicated load balancer like HAProxy (aka client-side load balancing)

---

<div class="post-metadata">

**Author:** ![Wayne\_Shen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_shen/32/49847_2.png) [@Wayne\_Shen](https://discuss.elastic.co/u/Wayne_Shen)\
**Post date:** [July 15, 2019, 2:20am UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/5 "2019-07-15T02:20:21Z")

</div>

Thanks for you reply. @felixbarny

I have tried your solution, it works perfectly.

---

<div class="post-metadata">

**Author:** ![Wayne\_Shen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wayne_shen/32/49847_2.png) [@Wayne\_Shen](https://discuss.elastic.co/u/Wayne_Shen)\
**Post date:** [July 15, 2019, 2:34am UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/6 "2019-07-15T02:34:32Z")

</div>

Thanks for sharing.

Actually my solution is behind corporate proxy, the proxy is used to sent traffic from Java agent to apm server.

@felixbarny's answer solved my problem.

---

<div class="post-metadata">

**Author:** ![digitalron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/digitalron/32/38224_2.png) [@digitalron](https://discuss.elastic.co/u/digitalron)\
**Post date:** [July 15, 2019, 1:41pm UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/7 "2019-07-15T13:41:14Z")

</div>

Thanks for the clarification @felixbarny

(Without intending to hijack this thread) Just a note on why we we used a client-side proxy: it was easier for us to abstract the resultant APM Servers this way. As the server\_urls config is not dynamically reloaded, by putting the APM Servers behind HAProxy or BigIP, we can easily scale the APM Servers as well as move the target APM Servers whenever we want without having to reload the instrumented services. I could not find any other way to do this in such a scenario. We're definitely open to suggestions 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 5, 2019, 9:43am UTC](https://discuss.elastic.co/t/intranet-solution-java-agent-send-metric-to-cloud-apm-server-via-proxy-server/190153/8 "2019-08-05T09:43:03Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
