# APM with Apache proxy

**URL:** <https://discuss.elastic.co/t/apm-with-apache-proxy/173084>\
**Category:** APM\
**Created:** [March 20, 2019, 7:05am UTC](https://discuss.elastic.co/t/apm-with-apache-proxy/173084 "2019-03-20T07:05:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tflorac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tflorac/32/42393_2.png) [@tflorac](https://discuss.elastic.co/u/tflorac)\
**Post date:** [March 20, 2019, 7:05am UTC](https://discuss.elastic.co/t/apm-with-apache-proxy/173084/1 "2019-03-20T07:05:12Z")

</div>

**Elasticsearch version** : 6.6.2 (Free license)

**APM Server version** : 6.6.2

**APM Agent language and version** : Java 1.4.0

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: deb

**Fresh install or upgraded from other version?** : Fresh install

**Is there anything special in your setup?** Apache proxy frontend

I'm trying to configure an Apache proxy in front of my APM server to filter IP addresses which are allowed to connect to my APM server and add authentication.  
With the Java agent, and simple Apache ProxyPass/ProxyPassReverse configuration, I always get 408 proxy timeout errors (which I don't get while using the Python agent, or when connecting directly to APM server).  
I tried to increase ProxyTimeout but this doesn't seems to work!  
So which Apache configuration should I use to be able to use Java agent this way?  
Best regards,  
Thierry

---

<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:** [March 20, 2019, 7:45am UTC](https://discuss.elastic.co/t/apm-with-apache-proxy/173084/2 "2019-03-20T07:45:03Z")

</div>

Hi Thierry,

Can you share your Apache config please?  
Also, to clarify your question, is this correct:

```
BAD: JavaAgent ----------- Apache ---------> APM
GOOD: JavaAgent ----------------------------> APM
GOOD: PythonAgent ---------- Apache --------> APM
GOOD: PythonAgent --------------------------> APM

```

Is it possibly a firewall issue between the JavaAgent and Apache?

Regards,

Ronald

---

<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:** [March 20, 2019, 8:03am UTC](https://discuss.elastic.co/t/apm-with-apache-proxy/173084/3 "2019-03-20T08:03:04Z")

</div>

Hi 🙂

Unlike the Python agent, the Java agent uses chunked-encoding to stream the tracing data to the APM Server. By default, it keeps the HTTP request open for 10 seconds. This interval is configurable via [`api_request_time`](https://github.com/elastic/apm-agent-java/edit/1.x/docs/configuration.asciidoc).

That means that your proxy has to have a timeout which is higher than 10 seconds. You should also set the [`proxy-sendchunked`](https://httpd.apache.org/docs/2.4/mod/mod_proxy_http.html) flag, so that Apache does not buffer the chunks but directly sends them to the APM Server. This is not strictly required but recommended for efficiency.

See also this blog for more information about the protocol: [https://www.elastic.co/blog/increasing-memory-efficiency-with-an-improved-elastic-apm-internal-intake-protocol](https://www.elastic.co/blog/increasing-memory-efficiency-with-an-improved-elastic-apm-internal-intake-protocol)

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![tflorac](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tflorac/32/42393_2.png) [@tflorac](https://discuss.elastic.co/u/tflorac)\
**Post date:** [March 20, 2019, 4:52pm UTC](https://discuss.elastic.co/t/apm-with-apache-proxy/173084/4 "2019-03-20T16:52:49Z")

</div>

Yes Ronald, your diagram is correct!

This is the main sample of my Apache configuration:

```
ProxyPass / [http://127.0.0.1:8200/](http://127.0.0.1:8200/)

ProxyPassReverse / [http://127.0.0.1:8200/](http://127.0.0.1:8200/)

Timeout 600

<Location />

    AuthType Basic

    AuthName "APM server authentication"

    AuthBasicProvider file

    AuthUserFile "/etc/apache2/users.conf"

    Require user apm

    # Local access

    Require ip 127.0.0.1

    # Remote access

    Require ip 172.22.201.21

</Location>

```

Best regards,

Thierry

Le mer. 20 mars 2019 à 08:55, Ronald Tumulak via Discuss the Elastic Stack [elastic@discoursemail.com](mailto:elastic@discoursemail.com) a écrit :

---

<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:** [April 10, 2019, 12:52pm UTC](https://discuss.elastic.co/t/apm-with-apache-proxy/173084/5 "2019-04-10T12:52:55Z")

</div>

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