# 示例文件,按照你的情况更改,我的PHP配置请勿照搬,用你自己的。 # 必须将 ./data/config.json ./data/iconList.json 设置403。 server { listen 80; listen 443 ssl; listen 443 quic; #require Nginx http/3 module. listen [::]:80; listen [::]:443 ssl; listen [::]:443 quic; #require Nginx http/3 module. http2 on; server_name www.example.com; index index.php default.php index.html index.htm default.htm default.html; root /www/example; # SSL-START ssl_certificate /www/example/fullchain.pem; ssl_certificate_key /www/example/privkey.pem; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; add_header Alt-Svc 'quic=":443"; h3=":443"; h3-29=":443"; h3-27=":443";h3-25=":443"; h3-T050=":443"; h3-Q050=":443";h3-Q049=":443";h3-Q048=":443"; h3-Q046=":443"; h3-Q043=":443"'; error_page 497 https://$host$request_uri; # SSL-END # PHP-INFO-START location ~ [^/]\.php(/|$) { try_files $uri =404; fastcgi_pass unix:/www/php/php-cgi-83.sock; fastcgi_index index.php; include fastcgi.conf; include pathinfo.conf; } # PHP-INFO-END # 精确匹配:只有当请求的 URI 完全等于 /data/config.json 时才会匹配。 location = /data/config.json { deny all; return 403; } location = /data/iconList.json { deny all; return 403; } # 禁止访问的文件或目录 location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md|README_zh-CN.md|.gitignore) { return 404; } access_log /dev/null; error_log /var/log/wwwlog/www.example.com.error.log; }