Azure PHP8 公开 php 代码

Azure PHP8 公开 php 代码

我的网站运行正常,但是当我将大写的“.PHP”添加到我的 URL 中时,例如www.example.com/test.PHP我的php代码暴露在网站源代码中。

我在 Azure 上运行 PHP8。

我的 NGIX 配置如下:

server {
#proxy_cache cache;
#proxy_cache_valid 200 1s;
listen 8080;
listen [::]:8080;
root /home/site/wwwroot;
index  index.php;
server_name  example.net www.example.net; 
port_in_redirect off;

default_type text/html;

location / {
    try_files $uri $uri/ @ext;
}

location ~ \/\.php {
    rewrite "^(.*)\/.php" $1.php last;
}

location @ext {
    rewrite "^(.*)$" $1.php;
}

location ~ \/\.php {
    deny all;
    access_log off;
    log_not_found off;
}

error_page 403 404  /error.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
    fastcgi_param HTTP_PROXY "";
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_intercept_errors on;
    fastcgi_connect_timeout         300; 
    fastcgi_send_timeout           3600; 
    fastcgi_read_timeout           3600;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
}
}

我实在想不出如何解决这个问题。

更新

下面添加了现在将其重定向到错误页面

  location ~ \.PHP$ {
    deny all;
    access_log off;
    log_not_found off;
  } 

相关内容