Различия
Показаны различия между двумя версиями страницы.
| Предыдущая версия справа и слеваПредыдущая версия | |||
| linux:cloudflare_ssl_full_strict [2023/07/22 15:58] – dx | linux:cloudflare_ssl_full_strict [2023/07/22 16:01] (текущий) – dx | ||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| + | ====== Cloudflare: SSL сертификаты Full Strict ====== | ||
| + | Получаем бесплатные wildcard сертификаты от Cloudflare. | ||
| + | |||
| + | ===== Cloudflare ===== | ||
| + | |||
| + | Переходим в [[https:// | ||
| + | |||
| + | 1️⃣ SSL/TLS → Origin Server → Create Certificate | ||
| + | |||
| + | {{: | ||
| + | |||
| + | 2️⃣ Выбираем тип RSA | ||
| + | |||
| + | {{: | ||
| + | |||
| + | 3️⃣ | ||
| + | |||
| + | {{: | ||
| + | |||
| + | 4️⃣ SSL/TLS → Origin Server → Authenticated Origin Pulls | ||
| + | |||
| + | {{: | ||
| + | |||
| + | 5️⃣ SSL/TLS → Overview → Full (strict) | ||
| + | |||
| + | {{: | ||
| + | |||
| + | Теперь всё это добро нужно куда-нибудь сохранить. Кому как удобней: | ||
| + | |||
| + | * ''/ | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | |||
| + | Должно быть 3 файла | ||
| + | |||
| + | <code bash> | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | Где взять origin_rsa см. ниже | ||
| + | |||
| + | ===== Origin pull CA ===== | ||
| + | |||
| + | Скачать PEM файл [[https:// | ||
| + | |||
| + | Apache | ||
| + | |||
| + | <code bash> | ||
| + | SSLVerifyClient require | ||
| + | SSLVerifyDepth 1 | ||
| + | SSLCACertificateFile / | ||
| + | </ | ||
| + | |||
| + | nginx | ||
| + | |||
| + | <code bash> | ||
| + | ssl_client_certificate / | ||
| + | ssl_verify_client on; | ||
| + | </ | ||
| + | |||
| + | ===== Cloudflare Root сертификат ===== | ||
| + | |||
| + | Этот шаг необязательный. При желании можно собрать полную цепочку сертификатов. | ||
| + | |||
| + | Чтобы добавить корневые сертификаты Cloudflare в сертификат Origin, необходимо загрузить и объединить их (ca+origin). | ||
| + | |||
| + | Для RSA private keys | ||
| + | |||
| + | <code bash> | ||
| + | wget -O cloudflare_root.pem https:// | ||
| + | </ | ||
| + | |||
| + | Для ECDSA private keys | ||
| + | |||
| + | <code bash> | ||
| + | wget -O cloudflare_root.pem https:// | ||
| + | </ | ||
| + | |||
| + | Объединить | ||
| + | |||
| + | <code bash> | ||
| + | cat foobar.com_cert.pem cloudflare_root.pem > foobar.com_cert_full.pem | ||
| + | </ | ||
| + | |||
| + | ===== Nginx ===== | ||
| + | |||
| + | Конфигурационный файл | ||
| + | |||
| + | <code bash> | ||
| + | server { | ||
| + | listen 80; | ||
| + | # listen [::]:80; | ||
| + | server_name punx.cc www.punx.cc; | ||
| + | return 301 https:// | ||
| + | } | ||
| + | |||
| + | server { | ||
| + | listen 443 http2 ssl; | ||
| + | # listen [::]:443 http2 ssl; | ||
| + | |||
| + | server_name punx.cc www.punx.cc; | ||
| + | |||
| + | root / | ||
| + | index index.html index.php; | ||
| + | |||
| + | location / { | ||
| + | try_files $uri $uri/ =404; | ||
| + | } | ||
| + | |||
| + | ssl_certificate | ||
| + | ssl_certificate_key | ||
| + | ssl_client_certificate / | ||
| + | ssl_verify_client on; | ||
| + | |||
| + | ssl_protocols TLSv1.2 TLSv1.3; | ||
| + | ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256: | ||
| + | ssl_prefer_server_ciphers off; | ||
| + | |||
| + | ssl_stapling on; | ||
| + | ssl_stapling_verify on; | ||
| + | |||
| + | resolver 1.1.1.1 1.0.0.1 valid=300s; | ||
| + | resolver_timeout 10s; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Apache ===== | ||
| + | |||
| + | <code bash> | ||
| + | < | ||
| + | Redirect permanent / https:// | ||
| + | ServerName | ||
| + | ServerAlias www.punx.cc | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | ServerName | ||
| + | ServerAlias www.punx.cc | ||
| + | DocumentRoot / | ||
| + | #ErrorLog ${APACHE_LOG_DIR}/ | ||
| + | #CustomLog ${APACHE_LOG_DIR}/ | ||
| + | |||
| + | SSLEngine on | ||
| + | SSLCertificateFile | ||
| + | SSLCertificateKeyFile | ||
| + | SSLCertificateChainFile / | ||
| + | |||
| + | SSLProtocol | ||
| + | SSLHonorCipherOrder | ||
| + | SSLCipherSuite | ||
| + | |||
| + | < | ||
| + | Header always edit Set-Cookie ^(.*)$ $1; | ||
| + | #Header always set Strict-Transport-Security " | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== Проверка ===== | ||
| + | |||
| + | Проверяем домен на сайте [[https:// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | ===== Real IP ===== | ||
| + | |||
| + | Для отображения реального IP посетителя сайта | ||
| + | |||
| + | ==== nginx ==== | ||
| + | |||
| + | <code bash> | ||
| + | set_real_ip_from 173.245.48.0/ | ||
| + | set_real_ip_from 103.21.244.0/ | ||
| + | set_real_ip_from 103.22.200.0/ | ||
| + | set_real_ip_from 103.31.4.0/ | ||
| + | set_real_ip_from 141.101.64.0/ | ||
| + | set_real_ip_from 108.162.192.0/ | ||
| + | set_real_ip_from 190.93.240.0/ | ||
| + | set_real_ip_from 188.114.96.0/ | ||
| + | set_real_ip_from 197.234.240.0/ | ||
| + | set_real_ip_from 198.41.128.0/ | ||
| + | set_real_ip_from 162.158.0.0/ | ||
| + | set_real_ip_from 104.16.0.0/ | ||
| + | set_real_ip_from 104.24.0.0/ | ||
| + | set_real_ip_from 172.64.0.0/ | ||
| + | set_real_ip_from 131.0.72.0/ | ||
| + | |||
| + | # | ||
| + | real_ip_header X-Forwarded-For; | ||
| + | </ | ||
| + | |||
| + | ==== apache ==== | ||
| + | |||
| + | === Debian/ | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | / | ||
| + | |||
| + | RemoteIPHeader CF-Connecting-IP | ||
| + | ErrorLog ${APACHE_LOG_DIR}/ | ||
| + | CustomLog ${APACHE_LOG_DIR}/ | ||
| + | |||
| + | Заменить LogFormat в '' | ||
| + | |||
| + | Меняем | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | на | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | Добавляем в файл ''/ | ||
| + | |||
| + | <code bash> | ||
| + | RemoteIPHeader CF-Connecting-IP | ||
| + | RemoteIPTrustedProxy 173.245.48.0/ | ||
| + | RemoteIPTrustedProxy 103.21.244.0/ | ||
| + | RemoteIPTrustedProxy 103.22.200.0/ | ||
| + | RemoteIPTrustedProxy 103.31.4.0/ | ||
| + | RemoteIPTrustedProxy 141.101.64.0/ | ||
| + | RemoteIPTrustedProxy 108.162.192.0/ | ||
| + | RemoteIPTrustedProxy 190.93.240.0/ | ||
| + | RemoteIPTrustedProxy 188.114.96.0/ | ||
| + | RemoteIPTrustedProxy 197.234.240.0/ | ||
| + | RemoteIPTrustedProxy 198.41.128.0/ | ||
| + | RemoteIPTrustedProxy 162.158.0.0/ | ||
| + | RemoteIPTrustedProxy 104.16.0.0/ | ||
| + | RemoteIPTrustedProxy 104.24.0.0/ | ||
| + | RemoteIPTrustedProxy 172.64.0.0/ | ||
| + | RemoteIPTrustedProxy 131.0.72.0/ | ||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | |||
| + | === CentOS === | ||
| + | |||
| + | В CentOS модуль remoip уже загружен. Добавляем в файл ''/ | ||
| + | |||
| + | <code bash> | ||
| + | RemoteIPHeader X-Forwarded-For | ||
| + | RemoteIPTrustedProxy 173.245.48.0/ | ||
| + | # и далее все адреса CF | ||
| + | </ | ||
| + | |||
| + | В файле ''/ | ||
| + | |||
| + | <code bash> | ||
| + | LogFormat "%h %l %u %t \" | ||
| + | </ | ||
| + | |||
| + | на | ||
| + | |||
| + | <code bash> | ||
| + | LogFormat "%a %l %u %t \" | ||
| + | </ | ||
| + | |||
| + | ===== Ссылки ===== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | EOM | ||
| + | |||
| + | {{tag> | ||