官术网_书友最值得收藏!

  • NGINX Cookbook
  • Tim Butler
  • 176字
  • 2021-07-03 00:04:24

How it works...

Based on a simple PHP-FPM structure, we make a few key changes specific to the Drupal environment. The first change is as follows:

location ~ (^|/)\. { 
    return 403; 
} 

We put a block in for any files beginning with a dot, which are normally hidden and/or system files. This is to prevent accidental information leakage:

location ~ /vendor/.*\.php$ { 
    deny all; 
    return 404; 
} 

Any PHP file within the vendor directory is also blocked, as they shouldn't be called directly. Blocking the PHP files limits any potential exploit opportunity which could be discovered in third-party code.

Lastly, Drupal 8 changed the way the PHP functions are called for updates, which causes any old configuration to break. The location directive for the PHP files looks like this:

location ~ \.php$|^/update.php { 

This is to allow the distinct pattern that Drupal uses, where the PHP filename could be midway through the URI.

We also modify how the FastCGI process splits the string, so that we ensure we always get the correct answer:

fastcgi_split_path_info ^(.+?\.php)(|/.*)$; 
主站蜘蛛池模板: 牟定县| 吴堡县| 桐庐县| 惠水县| 广德县| 明水县| 买车| 通海县| 铜梁县| 长泰县| 讷河市| 屯门区| 丽江市| 南靖县| 仁布县| 曲阜市| 铜陵市| 油尖旺区| 墨江| 沛县| 鄂温| 临沭县| 大姚县| 池州市| 上蔡县| 姚安县| 柯坪县| 宝坻区| 黄山市| 江山市| 永昌县| 神池县| 偃师市| 桐庐县| 即墨市| 洞口县| 华容县| 桓台县| 宜昌市| 泊头市| 巨鹿县|