我们在一台服务器上安装了常规网站( http://example.com )和networking邮件( https://example.com/mail 。
为了保护免受DDoS攻击,我们使用CloudFlare免费版本。
所以问题是:当closuresCF时,一切正常 – 可以访问网站和networking邮件。 但是当打开CF保护 – 网站是可以的,但是networking邮件说SSL中的“太多redirect”。
试图设置如上所述 – 没有任何变化。
似乎在CF规则redirect规则中的一些错误configuration,或者ngnix – 无法理解。 但是哪里?
/etc/nginx/sites-enabled/example.com (网站):
server { listen 80; server_name example.com; server_name_in_redirect off; root /var/www/example.com; index index.php index.html index.htm default.html default.htm; location / { try_files $uri $uri/ /index.php?$args;. } location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ { return 403; error_page 403 /403_error.html; } location ~* \.(ico|pdf|flv)$ { expires 1y; } location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ { expires 14d; } include /etc/nginx/templates/php-catchall.tmpl; include /etc/nginx/templates/redirect_to_https.tmpl; include /etc/nginx/templates/misc.tmpl; }
/etc/nginx/sites-enabled/example.com_443 (networking邮件):
server { listen 443; server_name mail.example.com; ssl on; ssl_certificate /etc/ssl/certs/iRedMail.crt; ssl_certificate_key /etc/ssl/private/iRedMail.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-R ssl_prefer_server_ciphers on; ssl_dhparam /etc/ssl/dh2048_param.pem; index index.php index.html; location / { root /opt/www/roundcubemail; } # Web applications. include /etc/nginx/templates/roundcube.tmpl; include /etc/nginx/templates/iredadmin.tmpl; include /etc/nginx/templates/php-catchall.tmpl; include /etc/nginx/templates/misc.tmpl;
}
CF规则:
https://example.com/mail SSL:Flexible - Full
启用example.com (DNS Alogging)的CF保护时, mail.example.com进入redirect循环。
问题出在了cloudflare服务的DNSlogging上。 这是像这样的:
... example.com. 300 IN A 1.2.3.4 www 300 IN A 1.2.3.4 mail 300 IN A 1.2.3.4 ...
将Alogging更改为CNAME,如下所示:
... example.com. 300 IN A 1.2.3.4 www.example.com. 300 IN CNAME example.com. mail.example.com. 300 IN CNAME example.com. ...
做了这件事。
您可以将CF的DNS中的所有内容直接指向IP地址,而不需要通过caching – 因为CF不接受除HTTP和HTTPS之外的任何其他协议。 所以你可以将这些logging返回给Alogging,只需在条目旁边禁用橙色的小云。
希望这可以帮助。
这里是一个如何设置DNS的例子。 指定您希望通过启用橙色云的CFcaching的所有内容,并且在没有启用橙色云的情况下指定所有内容。 这允许Alogging完全绕过它,如上所述。 为了pipe理方便,我使用了别名来显示它,但是如果您执行DNS查找,则会得到完全相同的结果。
![]()