Certbotの設定が終わり証明書が取得できたので、実際のサービス用のHAProxyの設定を行う
HAProxy用の証明書の作成。fullchain.pemとprivkey.pemを一つのファイルにまとめる
root@vmi1390183:~# lxc shell lt01
root@lt01:~# cd /etc/letsencrypt/live/lt.gp7.info
root@lt01:/etc/letsencrypt/live/lt.gp7.info# cat ./fullchain.pem ./privkey.pem > lt.gp7.info.pem
root@lt01:/etc/letsencrypt/live/lt.gp7.info# ls
cert.pem chain.pem fullchain.pem lt.gp7.info.pem privkey.pem README作成したファイルをホストに一旦ダウンロードし、HAProxyサーバにアップロード
root@vmi1390183:~# lxc file pull lt01/etc/letsencrypt/live/lt.gp7.info/lt.gp7.info.pem ./
root@vmi1390183:~# lxc file push ./lt.gp7.info.pem px01/etc/haproxy/certs/lt.gp7.info.pemHAProxyにサービス用の設定を追加
# frontend設定
frontend https
# 証明書ファイルの指定
bind *:443 ssl crt /etc/haproxy/certs/www.gp7.info.pem crt /etc/haproxy/certs/rm.gp7.info.pem crt /etc/haproxy/certs/zbx.gp7.info.pem crt /etc/haproxy/certs/lt.gp7.info.pem
# サービス用URLのACL設定
acl leantime-host hdr(host) -i lt.gp7.info
# ACLに該当する通信をbackendにルーティング
use_backend be-http-leantime if leantime-host
# backend 設定
backend be-http-leantime
http-request add-header X-Forwarded-Proto https
server leantime-http lt01:80 check設定のチェックとリロードして完了
root@px01:/etc/haproxy# haproxy -c -- ./haproxy.cfg
Configuration file is valid
root@px01:/etc/haproxy# systemctl reload haproxy
コメント