我试图使用haproxy作为代理服务器来设置基本的基础架构。
这是我的基本环境
域名: example.com
代理服务器
代理configuration文件:已经添加/configuration了这两个部分
frontend http-frontend bind 100.100.100.101:80 reqadd X-Forwarded-Proto:\ http default_backend webserver backend webserver server 1-www 100.100.100.102:80 check #server 2-www private_ip_2:80 check # use for load balance
networking服务器
DNS指向我的代理IP:100.100.100.101
Type A 100.100.100.101 CNAME example.com
Obs .:在浏览器中调用域名时,redirect没有任何问题,但是没有下载来自Web服务器的内容(我得到了无法连接错误)。 我已经安装让我们encryption在我的Web服务器IP:100.100.100.102,也许这是造成这个问题? 同样在我的nginxconfiguration文件中,我创build了一个规则来redirect从HTTP到HTTPS,以防万一用户忘记使用https://。
我的疑问是,我是否应该在我的代理服务器或Web服务器(实际安装)中安装Let's Encrypt?
谢谢。
毕竟,这是我的haproxyconfiguration文件的样子,对于那些感兴趣的,它是在我的环境中工作。
global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy stats socket /run/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 # 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 maxconn 2048 tune.ssl.default-dh-param 2048 defaults log global mode http option forwardfor option http-server-close 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 frontend www-http bind 100.100.100.101:80 reqadd X-Forwarded-Proto:\ http default_backend wwwbackend frontend www-https bind 100.100.100.101:443 ssl crt /etc/haproxy/certs/mydomain.tld.pem reqadd X-Forwarded-Proto:\ https acl letsencrypt-acl path_beg /.well-known/acme-challenge/ use_backend letsencrypt-backend if letsencrypt-acl default_backend wwwbackend backend wwwbackend redirect scheme https if !{ ssl_fc } server mamba 100.100.100.102:80 check server taipan 100.100.100.103:80 check server viper 100.100.100.104:80 check server cobra 100.100.100.105:80 check backend letsencrypt-backend server letsencrypt 127.0.0.1:22222
您将用户redirect到HTTPS,并且您的haproxyconfiguration缺lessHTTPSconfiguration。 您需要configuration您的haproxy侦听端口443,并将请求传递给您的nginx后端。 您还需要在haproxy上安装Let's Encrypt证书。