| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- server {
- listen 80;
- server_name bot28api.sp2509.cc;
- root /var/www/html/public; # 必须指向 public 目录
- index index.php index.html;
- location / {
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization';
- add_header 'Access-Control-Allow-Credentials' 'true';
- add_header 'Access-Control-Max-Age' 3600;
- if ($request_method = 'OPTIONS') {
- # OPTIONS 请求直接返回 200
- return 204;
- }
- #try_files $uri $uri/ /index.php?$query_string;
- if (!-e $request_filename) {
- rewrite ^/index.php(.*)$ /index.php?s=$1 last;
- rewrite ^(.*)$ /index.php?s=$1 last;
- break;
- }
- }
- # ===== PHP 解析配置(强制指向 8.4,避免版本问题)=====
- location ~ \.php$ {
- fastcgi_pass app:9000; # 确认是 8.4 的 sock 文件
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
- fastcgi_param DOCUMENT_ROOT $realpath_root;
- include fastcgi_params;
- }
- # ===== 禁止访问敏感文件/目录(保留)=====
- location ~ /\.(?!well-known).* {
- deny all;
- }
- location ~ ^/(\.user.ini|\.htaccess|\.git|\.env) {
- return 404;
- }
- # ===== 静态文件缓存(保留,不影响接口)=====
- location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
- expires 30d;
- add_header Cache-Control "public, max-age=2592000";
- access_log off;
- }
- # ===== 日志配置(保留)=====
- access_log /var/log/nginx/bot28api.sp2509.cc.log;
- error_log /var/log/nginx/bot28api.sp2509.cc.error.log;
- }
|