ウェブサイト検索

Let's Encrypt SSL を使用して Graylog Nginx プロキシを構成する |


Let's Encrypt SSL を使用した Graylog Nginx リバース プロキシの構成に関するガイドへようこそ。 Graylog に関連する最後のチュートリアルは、Ubuntu/CentOS 7/CentOS 8 Linux システムに Graylog サーバーをインストールする方法でした。 Graylog のすべてのセットアップ手順をかなり詳しく説明しました。唯一の欠点は、検証済みの SSL 証明書がなければ、IP アドレスとポート番号を使用して Graylog UI にアクセスする必要があることです。

このガイドでは、Let’s Encrypt SSL を使用して Graylog Nginx リバース プロキシを構成する方法を見ていきたいと思います。このようにして、検証済みの SSL 証明書を持つドメインまたはホスト名を使用できます。

Let’s Encrypt SSL を使用して Graylog Nginx リバース プロキシを構成する

最初のステップは、Graylog で使用する証明書をリクエストするために使用する certbot のような Let’s Encrypt クライアントをインストールすることです。

certbot Let’s Encrypt SSL ツールをインストールする

次のコマンドを実行して、cerbot ツールをインストールします。

# Ubuntu / Debian
sudo apt update
sudo apt install certbot

# Fedora
sudo dnf install certbot

# CentOS 8 / CentOS 7
sudo yum -y install epel-release
sudo yum -y install certbot

バージョンを確認してインストールを確認します。

$ certbot --version
certbot 1.21.0

ファイアウォールで https ポートを開く

http ポートを使用して SSL 証明書をリクエストするため、ファイアウォールで開きます。 ufw または iptables を使用している場合は、ここでのコマンドを同等のコマンドに置き換えてください。

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

nginx サービスが実行されている場合は停止します。

sudo systemctl stop nginx

SSL証明書のリクエスト

certbot-auto コマンドを使用して Let’s Encrypt 証明書をリクエストします。

export DOMAIN='graylog.mydomain.com'
export EMAIL="[email "
sudo certbot certonly --standalone -d $DOMAIN --preferred-challenges http --agree-tos -n -m $EMAIL --keep-until-expiring

これには、依存関係のブートストラップ、Python 仮想環境の作成、Python パッケージのインストールから始まり、最後に証明書の生成が行われるため、しばらく時間がかかる場合があります。コマンドが証明書が正常に生成されたという応答を返すまで待ちます。

成功メッセージは次のようになります。

.....
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/domain.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/domain.com/privkey.pem Your cert will expire on 2018-06-07. To obtain a new or tweaked
version of this certificate in the future, simply run certbot-auto
again. To non-interactively renew *all* of your certificates, run
"certbot-auto renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

Nginxのインストールと設定

次に、Nginx をインストールして構成する必要があります。

# CentOS / RHEL
sudo yum -y install nginx 

# Ubuntu / Debian 
sudo apt install nginx

Graylog の nginx 設定を /etc/nginx/conf.d/graylog.conf に置きます。 domain.com を Graylog ドメイン/サブドメイン名に置き換えます。

server {
 listen 443 ssl;
 server_name graylog.mydomain.com;
 location / {
   proxy_set_header Host $http_host;
   proxy_set_header X-Forwarded-Host $host;
   proxy_set_header X-Forwarded-Server $host;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Graylog-Server-URL https://domain.com/api;
   proxy_pass http://127.0.0.1:9000;
   # proxy_pass http://ip-address:9000;
 }
 ssl on;
 ssl_certificate /etc/letsencrypt/live/graylog.mydomain.com/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/graylog.mydomain.com/privkey.pem;
 ssl_session_timeout 5m;
 ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
 ssl_protocols TLSv1.2;
 ssl_prefer_server_ciphers on;
 access_log /var/log/nginx/graylog.access.log;
 error_log /var/log/nginx/graylog.error.log;
}

# http to https redirection
server {
    listen 80;
    server_name graylog.mydomain.com;
    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://$server_name$request_uri? permanent;
}

設定を保存し、nginx で構文が有効かどうかを確認します。

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

nginxサービスを開始して有効にする

nginx サービスの開始と有効化に進みます。

sudo systemctl restart nginx
sudo systemctl enable nginx

指定したドメインにアクセスすると、https にリダイレクトされます。

「Let's Encrypt SSL を使用して Graylog Nginx リバース プロキシを構成する」ガイドが役に立ったことを願っています。次のチュートリアルでは、ストリーム、入力、ダッシュボードの作成について説明します。

ロギングに関するその他のガイド:

  • OpenShift/OKD 4.x に Cluster Logging Operator をインストールする
  • EKS Kubernetes クラスターで CloudWatch ログを有効にする
  • 永続ストレージを使用して Systemd ジャーナル ログを保存する

関連記事: