最近搜索

nginx 禁止访问所有html文件

浏览:11
管理员 2025-10-27 00:03




server {
    listen 443 ssl;
    server_name file.jikeng10.cn;
    
    root /usr/share/nginx/html;
    index index.html index.htm;

    ssl_certificate /etc/nginx/ssl/file.jikeng10.cn.pem;
    ssl_certificate_key /etc/nginx/ssl/file.jikeng10.cn.key;
    
    ssl_session_timeout 10m;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers on;
     # 禁止访问所有html文件
    location ~ \.html$ {
        deny all;
        return 403;
    }
    # 禁止访问的路径
     location ~ ^/(index|fileUpload) {
        return 403;
    }
    
    location / {
        proxy_pass http://117.72.168.145:8012;
        index index.html index.htm;
    }
}

server {
    listen 80;
    server_name file.jikeng10.cn;
    rewrite ^(.*)$ https://$host$1 permanent;
}


联系站长

站长微信:xiaomao0055

站长QQ:14496453