nes*_*eka 1 ubuntu ssl ruby-on-rails nginx
我正在尝试更改 Nginx ssl_protocols 的设置,但更改不会反映在服务器上。
起初我以为是因为我们使用的是 Ubuntu 12.04,但现在我们更新到了 14.04。
Nginx 版本:
nginx version: nginx/1.10.1
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
built with OpenSSL 1.0.1f 6 Jan 2014
TLS SNI support enabled
configure arguments: --sbin-path=/usr/local/sbin/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module
Run Code Online (Sandbox Code Playgroud)
Openssl 版本:
OpenSSL 1.0.1f 6 Jan 2014
Run Code Online (Sandbox Code Playgroud)
Ngnix.conf:
http {
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay off;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log debug;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
client_body_timeout 10;
client_header_timeout 10;
sendfile on;
# output compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types text/plain text/html text/css text/js application/x-javascript application/javascript application/json;
# include config for each site here
include /etc/nginx/sites/*;
Run Code Online (Sandbox Code Playgroud)
/etc/nginx/sites/site.conf:
server {
listen 443 ssl;
server_name server_name;
root /home/deploy/server_name/current/public;
access_log /var/log/nginx/server_name.access.log main;
ssl_certificate /usr/local/nginx/conf/ssl/wildcard.server_name.com.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/wildcard.server_name.com.key.unsecure;
ssl_client_certificate /usr/local/nginx/conf/ssl/geotrust.crt;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
ssl_prefer_server_ciphers on;
location ~ ^/assets/ {
expires max;
add_header Cache-Control public;
add_header ETag "";
break;
}
location / {
try_files $uri @server_name;
proxy_set_header X-Forwarded-Proto https;
}
location @server_name {
include proxy.conf;
proxy_pass http://server_name;
proxy_set_header X-Forwarded-Proto https;
}
# stats url
location /nginx_stats {
stub_status on;
access_log off;
}
}
Run Code Online (Sandbox Code Playgroud)
配置文件已正确加载并且都按预期使用。如果有任何相关性,服务器正在运行 Ruby on Rails 和 Unicorn。
有谁知道可能出了什么问题吗?
我有类似的问题。我的更改将被应用(nginx -t会警告重复和无效的值),但 TLSv1.0 和 TLSv1.1 仍会被接受。我的站点启用/文件中的行读取
ssl_protocols TLSv1.2 TLSv1.3;。
我跑去grep -R 'protocol' /etc/nginx/*找其他提到的 ssl_protocols,但我只找到了主配置文件/etc/nginx/nginx.conf和我自己的站点配置。
该问题是由 certbot/letsencrypt 包含的文件引起的,位于/etc/letsencrypt/options-ssl-nginx.conf. 在certbot 0.31.0 ( certbot --version) 中,该文件包含以下行:
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
这有点偷偷地启用了这些版本的 TLS。Libre Software向我透露了消息。0.31.0 是我能够获得的 Ubuntu 18.04 LTS 的最新版本
从certbot v0.37.0开始,TLS 版本 <1.2 在 certbot nginx 配置中默认被禁用(谢谢mnordhoff)。我将文件从那里复制到 LetsEncrypt 配置 ( options-ssl-nginx.conf) 中,为我自己和后续维护人员添加了一条注释,一切又恢复正常了。
grep 更高一级(/etc/* 而不是 /etc/nginx*)将使我能够找到罪魁祸首。但更可靠、更强大的工具是nginx -T,它打印出所有考虑的配置文件。其他有用的命令:
nginx -s reload更改配置后nginx -v找出你的 nginx 版本。要启用 TSL 版本 1.3,您需要版本 1.13.0+。openssl version:您至少需要OpenSSL 1.1.1“使用 TLSv1.3 支持构建”curl -I -v --tlsv<major.minor> <your_site>用于测试某个版本的 TLS 是否确实已启用journalctl -u nginx --since "10 minutes ago"绝对确保没有发生其他事情。| 归档时间: |
|
| 查看次数: |
4712 次 |
| 最近记录: |