メインコンテンツに移動
ネットワークを右往左往

メインナビゲーション

  • ホーム
  • 今日のご飯
  • 攻撃の履歴
ユーザーアカウントメニュー
  • ログイン

パンくず

  1. ホーム

[備忘録]サービス用HAProxy設定

By aki, 19 10月, 2025

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.pem

HAProxyにサービス用の設定を追加

# 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
  • コメントを投稿するにはログインまたは登録をしてください

コメント

AbuseIPDB Contributor Badge

本日の攻撃

20260105
CountryCount
kr67
lt143
nl51
pl1
ru1
us10
vn272
cn261
Powered by Drupal