LoginSignup
6
0

More than 3 years have passed since last update.

Apache を Elastic APM の Proxy にする

Last updated at Posted at 2020-12-08

この記事は、みらい翻訳 Advent Calendar 2020 9日目の記事です。

こんにちは、株式会社みらい翻訳 プラットフォーム部の@kobarasukimaroです。
2回目の登場です。 AWS のことを書こうと思いましたが色々ギリギリすぎて別のネタにしました。ご容赦ください。

この記事について

Elastic APM の RUM(Real User Monitoring)でブラウザから Elastic Cloud 上の Elastic APM に直接リクエストせず、 Apache を経由してリクエストを投げるのをやってみたので記述します。

環境

Apache 2.4
Elastic APM 7.9.2

内容

諸事情あって Elastic Cloud 上の Elastic APM に直接リクエストを投げられない状況でした。
さらに Nginx だと既にやっている方がいたので楽にできそうでしたが、 諸事情あって Apache を使わざるを得ない状況だったので試行錯誤して設定しました。

設定内容としてはこちらの設定を Apache の conf に置き換えたようなものになります。

<Location /intake>
  <If "%{REQUEST_METHOD} == 'OPTIONS'">
    Header set Access-Control-Allow-Origin *
    Header set Access-Control-Allow-Methods GET,POST,OPTIONS
    Header set Access-Control-Allow-Headers Accept:,Accept-Encoding,Accept-Language:,Cache-Control,Connection,DNT,Prag
ma,Host,Referer,Upgrade-Insecure-Requests,User-Agent,elastic-apm-traceparent
    Header set Access-Control-Max-Age 1728000
    Header set Access-Control-Allow-Credentials true
    Header set Content-Type 'text/plain; charset=utf-8'
    Header set Content-Length 0
  </If>
</Location>

RewriteEngine on
SSLProxyEngine On

RewriteCond %{REQUEST_METHOD} ^(GET|POST)$
RewriteRule ^/intake(.*)$ https://elastic_apm/intake$1 [P,
L]
ProxyPassReverse / https://elastic_apm/
RequestHeader append Access-Control-Allow-Origin *
RequestHeader append Access-Control-Allow-Credentials true

使用しているモジュールとしては以下になります。

  • mod_ssl
  • mod_proxy
  • mod_headers
  • mod_rewrite

詳細な解説

すみません、時間があるときに追記します😭

最後に

Elastic APM に Apache の Proxy 経由でリクエスト投げたいという杞憂な方が居りましたらご活用ください🙇‍♂️

次回は来週 @mitono がスポットインスタンスについて書くそうです!
その前に誰かカレンダーを埋めそうな気もしてます😁

6
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
0