CentOS 7
Sponsored Link

HAProxy : SSL の設定2015/02/18

 
HAProxy サーバーの SSL 設定です。
クライント - HAproxy サーバー間の通信が SSL 対応になります。( HAproxy - バックエンド間は通常通信 )
前項で例示した以下のような環境をベースに設定します。
       |
-------+-----------------------------------------------
       |
       +-------------------+--------------------+
       |10.0.0.30          |10.0.0.31           |10.0.0.32
 +-----+-----+     +-------+------+     +-------+------+
 | Frontend  |     |   Backend#1  |     |   Backend#2  |
 |  HAProxy  |     |  Web Server  |     |  Web Server  |
 +-----------+     +--------------+     +--------------+

[1] SSL 証明書を作成しておきます。
[root@dlp ~]#
cd /etc/pki/tls/certs

[root@dlp certs]#
openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/pki/tls/certs/haproxy.pem -out /etc/pki/tls/certs/haproxy.pem -days 365

Generating a 2048 bit RSA private key
......++++++
.......++++++
writing new private key to '/etc/pki/tls/certs/haproxy.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
JP
   
# 国

State or Province Name (full name) [Some-State]:
Hiroshima
   
# 地域(県)

Locality Name (eg, city) []:
Hiroshima
   
# 都市

Organization Name (eg, company) [Internet Widgits Pty Ltd]:
GTS
   
# 組織名

Organizational Unit Name (eg, section) []:
Server World
   
# 組織の部門名

Common Name (eg, YOUR name) []:
dlp.srv.world
   
# サーバーのFQDN

Email Address []:
root@srv.world
   
# 管理者アドレス
[root@dlp certs]#
chmod 600 haproxy.pem

[2] HAProxy の SSL 対応設定です。
[root@dlp ~]#
vi /etc/haproxy/haproxy.cfg
# global セクションの中へ追記

global
      # プロセス毎の最大SSL接続数

    maxsslconn     256
      # Diffie-Hellman キーを 2048 ビットにする

    tune.ssl.default-dh-param 2048

# frontend セクションの中へ追記

frontend  http-in
    bind *:80
      # 待ち受けポートと証明書を指定

    bind *:443 ssl crt /etc/pki/tls/certs/haproxy.pem

[root@dlp ~]#
systemctl restart haproxy

[3] 任意のクライアントからフロントエンドサーバーへ HTTPS アクセスして動作を確認してください。
関連コンテンツ