Last active
October 28, 2019 03:15
-
-
Save matsuu/384c2e090e0b09b7b8103ec78606a3d4 to your computer and use it in GitHub Desktop.
nginxでPATH_INFO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~ \.php(/|$) { | |
fastcgi_pass 127.0.0.1:9000; | |
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; | |
# $fastcgi_path_info は別変数に格納し直さないとなぜか使用できない | |
fastcgi_split_path_info ^(.*?\.php)(/.*); # CVE-2019-11043 | |
set $path_info $fastcgi_path_info; | |
# PATH_INFOを考慮するため$uriではなく$fastcgi_script_nameでチェック | |
try_files $fastcgi_script_name =404; | |
# PATH_TRANSLATEDはおまけ | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param PATH_INFO $path_info if_not_empty; | |
fastcgi_param PATH_TRANSLATED $document_root$path_info if_not_empty; | |
include fastcgi_params; | |
} | |
# ファイルやディレクトリが存在しない場合に/index.phpで処理する | |
location / { | |
try_files $uri $uri/ /index.php$is_args$args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment