NGINX применяет TLS 1.3, хотя я настроил TLS 1.2.

на моем сервере Debian 11 Bullseye 5.10.0-20-amd64

# nginx -V
nginx version: nginx/1.18.0
built with OpenSSL 1.1.1n  15 Mar 2022
TLS SNI support enabled

при использовании конфигурации SSL от mozilla (https://ssl-config.mozilla.org/#server=nginx&version=1.18.0&config=intermediate&openssl=1.1.1n&guideline=5.6), nginx применяет только TLS 1.3. Я не могу подключиться с TLS 1.2 к серверу.

* [CONN-0-0][CF-SSL] TLSv1.0 (OUT), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS handshake, Client hello (1):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Unknown (21):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS alert, protocol version (582):
* OpenSSL/3.0.7: error:0A00042E:SSL routines::tlsv1 alert protocol version
* Closing connection 0
curl: (35) OpenSSL/3.0.7: error:0A00042E:SSL routines::tlsv1 alert protocol version

Некоторые клиенты используют службы на моем сервере, которые не поддерживают TLS 1.3. Все они не могут подключиться на данный момент.

Кто-нибудь знает, почему этот f * nginx применяет только TLS 1.3?

В конфиге nginx нет строки (просматривал nginx -T), в которой написано только TLS 1.3. Я совершенно не понимаю, как это исправить, поэтому любая помощь или указания, где искать, очень ценятся.

nginx.conf

user www-data;
worker_processes 4;
worker_rlimit_nofile 25000;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
load_module modules/ngx_http_modsecurity_module.so;

events {
        worker_connections 4096;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        server_tokens off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log error;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_vary on;
        gzip_min_length 10240;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/sites-enabled/*.vhost;
}

default.vhost

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        server_name master.nerdvpn.de;

        location /.well-known/acme-challenge/ {
                allow all;
                default_type "text/plain";
                alias /var/www/acme/;
        }
}

server {
        listen 443 ssl http2 default_server;
        listen [::]:443 ssl http2 default_server;

        server_name master.nerdvpn.de;

        add_header X-Robots-Tag "none" always;

        ssl_certificate         /srv/letsencrypt/certs/master.nerdvpn.de/fullchain.pem;
        ssl_certificate_key     /srv/letsencrypt/certs/master.nerdvpn.de/privkey.pem;

        # https://ssl-config.mozilla.org/#server=nginx&version=1.18.0&config=intermediate&openssl=1.1.1n&guideline=5.6
        ssl_session_timeout 1d;
        ssl_session_cache shared:nginx_TLS_default:10m;  # about 40000 sessions
        ssl_session_tickets off;

        # curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam
        ssl_dhparam /srv/letsencrypt/dhparam.pem;

        # intermediate configuration
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
        ssl_prefer_server_ciphers off;

        # HSTS (ngx_http_headers_module is required) (63072000 seconds)
        add_header Strict-Transport-Security "max-age=63072000" always;

        # OCSP stapling
        ssl_stapling on;
        ssl_stapling_verify on;

        # verify chain of trust of OCSP response using Root CA and Intermediate certs
        ssl_trusted_certificate /srv/letsencrypt/ocsp/BPClass2CA2Bundle.pem;

        access_log off;
        error_log /var/log/nginx/errors/server.log;

        location / {
                deny all;
        }
}

nextcloud.vhost

upstream php-handler {
        server unix:/var/run/php/php-fpm.sock;
}

limit_req_zone $binary_remote_addr zone=nextcloud_login:8m rate=60r/m;

server {
                listen 80;
                listen [::]:80;

                server_name nerdvpn.de www.nerdvpn.de;

                location ^~ /.well-known/acme-challenge/ {
                                allow all;
                                default_type "text/plain";
                                alias /var/www/acme/;
                }

                location / {
                                return 301 https://$server_name:443$request_uri;
                }
}


server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name nerdvpn.de www.nerdvpn.de;

        ssl_certificate /srv/letsencrypt/certs/nerdvpn.de/fullchain.pem;
        ssl_certificate_key /srv/letsencrypt/certs/nerdvpn.de/privkey.pem;
        
        # https://ssl-config.mozilla.org/#server=nginx&version=1.18.0&config=intermediate&openssl=1.1.1n&guideline=5.6
        ssl_session_timeout 1d;
        ssl_session_cache shared:nginx_TLS_nx:10m;  # about 40000 sessions
        ssl_session_tickets off;

        # curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam
        ssl_dhparam /srv/letsencrypt/dhparam.pem;

        # intermediate configuration
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
        ssl_prefer_server_ciphers off;

        # HSTS (ngx_http_headers_module is required) (63072000 seconds)
        add_header Strict-Transport-Security "max-age=63072000" always;

        # OCSP stapling
        ssl_stapling on;
        ssl_stapling_verify on;

        # verify chain of trust of OCSP response using Root CA and Intermediate certs
        ssl_trusted_certificate /srv/letsencrypt/ocsp/BPClass2CA2Bundle.pem;

        access_log off;
        error_log /var/log/nginx/errors/nextcloud.log error;

        client_max_body_size 512M;
        fastcgi_buffers 64 4K;

        gzip on;
        gzip_vary on;
        gzip_comp_level 4;
        gzip_min_length 256;
        gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
        gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

        add_header Referrer-Policy "no-referrer" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Download-Options "noopen" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Permitted-Cross-Domain-Policies "none" always;
        add_header X-Robots-Tag "none" always;
        add_header X-XSS-Protection "1; mode=block" always;

        fastcgi_hide_header X-Powered-By;

        root /srv/nextcloud;

        index index.php index.html /index.php$request_uri;

        # Microsoft DAV clients
        location = / {
                if ( $http_user_agent ~ ^DavClnt ) {
                        return 302 /remote.php/webdav/$is_args$args;
                }
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location ^~ /.well-known {
                # The rules in this block are an adaptation of the rules
                # in `.htaccess` that concern `/.well-known`.

                location = /.well-known/carddav { return 301 /remote.php/dav/; }
                location = /.well-known/caldav  { return 301 /remote.php/dav/; }

                location /.well-known/acme-challenge    { try_files $uri $uri/ =404; }
                location /.well-known/pki-validation    { try_files $uri $uri/ =404; }

                return 301 /index.php$request_uri;
        }

        # Hide certain paths from clients
        location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)  { return 404; }
        location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)                                { return 404; }

        location ~ \.php(?:$|/) {
                rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;

                fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                set $path_info $fastcgi_path_info;

                try_files $fastcgi_script_name =404;

                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $path_info;
                fastcgi_param HTTPS on;

                fastcgi_param modHeadersAvailable true;
                fastcgi_param front_controller_active true;
                fastcgi_pass php-handler;

                fastcgi_intercept_errors on;
                fastcgi_request_buffering off;

                fastcgi_max_temp_file_size 0;
        }

        location ~ \.(?:css|js|svg|gif|png|jpg|ico|wasm|tflite|map)$ {
                try_files $uri /index.php$request_uri;
                expires 6M;              # Cache-Control policy borrowed from `.htaccess`
                access_log off;  # Optional: Don't log access to assets

                location ~ \.wasm$ {
                        default_type application/wasm;
                }
        }

        location ~ \.woff2?$ {
                try_files $uri /index.php$request_uri;
                expires 7d;              # Cache-Control policy borrowed from `.htaccess`
                access_log off;  # Optional: Don't log access to assets
        }

        location /remote {
                return 301 /remote.php$request_uri;
        }

        location /login {
                limit_req zone=nextcloud_login burst=12 delay=4;
                try_files $uri $uri/ /index.php$request_uri;
        }
        location / {
                try_files $uri $uri/ /index.php$request_uri;
        }
}

Ваше здоровье!

Вайденвизель

1 ответ
1

Я мог бы решить проблему, собрав nginx из исходников. Без изменений конфигурации теперь работает. Я не знаю почему, но nginx по умолчанию из репозиториев Debian отказывается использовать TLS 1.2 на моей машине.

* [CONN-0-0][CF-SSL] TLSv1.0 (OUT), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS handshake, Client hello (1):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Server hello (2):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Certificate (11):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Server finished (14):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS header, Finished (20):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS handshake, Finished (20):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Finished (20):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS header, Certificate Status (22):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-AES256-GCM-SHA384

Вайденвизель

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *