0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Healthcheck用のnginxの指定

Posted at

概要

bigipを使ってmonitorを作成した際、nginxのヘルスチェック用に応答ページを作成したいと思う事がある。その際には以下の手順で実施することが可能。

bigip側では、sendstringに送る内容を、receivestringには返答される内容を指定することができる。

例えば、以下のようなmonitorがある場合SendStringをcurlコマンドに直すと、
image.png

curl http://サーバのIPorドメイン/api/tool/checkdb.aspx

であり、
応答として

checkdb:OK

がきたらモニターを緑にするという内容になっている。

nginx側の手順

対象のサーバで、httpd,nginxなどのwebサーバをインストールする。ここでは、nginxをインストールする。

sudo yum install -y nginx

その後nginxの/etc/nginx/nginx.confを確認する。

その後、serverの欄の中のroot部分がどのようなパスになっているかを確認する。

ここでは/usr/share/nginx/htmlである。

編集内容
略
    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }
略

なので、単純にcurl ipアドレスorドメイン
をしたら、/usr/share/nginx/htmlの内容がcurlに表示される。なので、その配下に対象のディレクトリを作成する。

sudo mkdir -p /usr/share/nginx/html/api/tool/

その後、モニターのsendで問い合わせるファイルを作成する。

sudo vi /usr/share/nginx/html/api/tool/checkdb.aspx

内容はreceive stringと一緒の内容にする。ここでは checkdb:OK

編集内容
checkdb:OK

その後、nginxを起動させる。

sudo systemctl start nginx

そして、適当なサーバから、curl http://IPorドメイン/api/tool/checkdb.aspx
をして、checkdb:OKが返ってくることを確認する。

こうなれば、先ほど設定していたBIGIP側のモニタを設定していたpoolがAvailableになる。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?