环境
php 7.3.6 + nginx 1.17.0
处理
location ~ .*\.php(\/.*)*$ {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
client_max_body_size 50M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /api/v1/ {
if (!-e $request_filename){
rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;
}
}
location /portal/ {
try_files $uri $uri/ /portal/index.php?$query_string;
}
location /api/v1/portal-access {
if (!-e $request_filename){
rewrite ^/api/v1/(.*)$ /api/v1/portal-access/index.php last; break;
}
}
location ~ /reset/?$ {
try_files /reset.html =404;
}
location ^~ (data|api)/ {
if (-e $request_filename){
return 403;
}
}
location ^~ /data/logs/ {
deny all;
}
location ^~ /data/config.php {
deny all;
}
location ^~ /data/cache/ {
deny all;
}
location ^~ /data/upload/ {
deny all;
}
location ^~ /application/ {
deny all;
}
location ^~ /custom/ {
deny all;
}
location ^~ /vendor/ {
deny all;
}
location ~ /\.ht {
deny all;
}
更新 2019-06-13