Debian 常用配置记录

UFW 防火墙

apt install ufw
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 'Nginx Full'
ufw logging off
ufw enable

Fail2ban 防止暴力破解

apt install fail2ban

TCP BBR

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
sysctl net.ipv4.tcp_available_congestion_control
lsmod | grep bbr

Nginx

关闭日志

log_not_found       off;
access_log          off;
error_log           /dev/null;

隐藏信息

server_tokens       off;

proxy_hide_header   X-Powered-By;
proxy_hide_header   Server;

安全

SSL session

ssl_session_timeout 1d;
ssl_session_cache   shared:SSL:10m;
ssl_session_tickets off;

Mozilla Intermediate configuration (2020年推荐)

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;

OCSP Stapling

ssl_stapling        on;
ssl_stapling_verify on;
resolver            127.0.0.53 valid=60s;
resolver_timeout    2s;

NGINX要监听127.0.0.53,需要开启本地名称解析服务。

开启本地名称解析服务

systemctl enable --now systemd-resolved.service

开启服务后,DNS服务常驻127.0.0.53

上一篇:十款常用Linux系统介绍


下一篇:二进制源码打出符合UOS商店规范的deb包