HAProxyを使用してhttpsを介したSSHトンネルの設定

HAProxyを使用してhttpsを介したSSHトンネルの設定

私はApache Webサーバーを持つサーバーと、http(ポート80)とhttps(ポート443)で実行されているいくつかのWebサイトを持っています。 Apacheとユーザーの間のポート443でプロキシを使用したいと思います。存在するこのページ、これを行う方法のチュートリアルがあります。着信接続がSSHかどうかを自動的に検出し、SSHであれば自動的にポート22に転送するため、奇妙に聞こえます。

/etc/haproxy/haproxy.cfgそのリンクに記載されているようにHAProxyを設定しました。以下は私の設定ファイルです。

global
        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /etc/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy
        daemon

        # Default SSL material locations
#       ca-base /etc/ssl/certs
#       crt-base /etc/ssl/private
        ca-base /home/myuser/SSL/
        crt-base /home/myuser/SSL/

        # Default ciphers to use on SSL-enabled listening sockets.
        # For more information, see ciphers(1SSL). This list is from:
        #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
        ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
        ssl-default-bind-options no-sslv3

        tune.ssl.default-dh-param 2048


defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000
        errorfile 400 /etc/haproxy/errors/400.http
        errorfile 403 /etc/haproxy/errors/403.http
        errorfile 408 /etc/haproxy/errors/408.http
        errorfile 500 /etc/haproxy/errors/500.http
        errorfile 502 /etc/haproxy/errors/502.http
        errorfile 503 /etc/haproxy/errors/503.http
        errorfile 504 /etc/haproxy/errors/504.http

backend secure_http
    reqadd X-Forwarded-Proto:\ https
    rspadd Strict-Transport-Security:\ max-age=31536000
    mode http
    option httplog
    option forwardfor
    server local_http_server 127.0.0.1:80

backend ssh
    mode tcp
    option tcplog
    server ssh 127.0.0.1:22
    timeout server 2h

frontend ssl
    bind 0.0.0.0:443 ssl crt /home/myuser/SSL/certs.pem no-sslv3
    mode tcp
    option tcplog
    tcp-request inspect-delay 5s
    tcp-request content accept if HTTP
    acl client_attempts_ssh payload(0,7) -m bin 5353482d322e30
    use_backend ssh if !HTTP
    use_backend ssh if client_attempts_ssh
    use_backend secure_http if HTTP

質問:

このチュートリアルでは、Apacheは、HAProxyがこのポートにバインドされ、ユーザーからセキュアな接続を受け取るポート443を使用しないと仮定します。これは、Webサーバー上のすべてのWebサイトが443の代わりにポート80を使用し、仮想ホストでSSLエンジンを無効にするためにApache設定で多くのエントリを変更する必要があることを意味します。私はこれを避けたい!

もしそうなら、Apache設定を最小限に変更し(たとえば、ポート443を別のものに変更します)、HAProxyに接続をApache(SSH以外の場合)に転送させる方法はありますか?

詳細が必要な場合はお問い合わせください。

ベストアンサー1

別のポートにApacheを設定する必要があります。

インターネット-(443)----(443)-HAP-|------(22) SSH

                          |-----(Other port ex 8443) apache 

それ以外の場合は、https、ssh、xmppに適したsslhを使用してください。

おすすめ記事