events {
    worker_connections  1024;
}
user root;
http {
    include       mime.types;
    default_type  application/octet-stream;
    charset utf-8;
    charset_types text/plain text/css text/html application/json application/javascript;
    # HTTPS 基础配置（可复用）
    ssl_protocols TLSv1.2 TLSv1.3;  # 仅启用安全的TLS版本
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;

    # HTTP 80端口 - 重定向到HTTPS
    server {
        listen       80;
        server_name  nodn.net www.nodn.net;
        
        # 将所有HTTP请求重定向到HTTPS
        return 301 https://$host$request_uri;
    }

    # HTTPS 443端口 - 核心服务配置
    server {
        listen       443 ssl;  # 监听443端口并启用SSL
        server_name  nodn.net www.nodn.net;

        # SSL证书配置（请替换为你的证书实际路径）
        ssl_certificate      /etc/nginx/ssl/server.crt;    # 证书文件路径
        ssl_certificate_key  /etc/nginx/ssl/server.key;  # 私钥文件路径

        # 配置文件服务器路径
        location / {
            root /root/nginx/;        # 你的文件根目录
            autoindex on;             # 启用目录浏览
            autoindex_exact_size off; # 显示易读的文件大小（如MB/GB）
            autoindex_localtime on;   # 显示本地时间而非GMT时间
        }
    }
}
