Skip to content

Instantly share code, notes, and snippets.

@matsuu matsuu/nginx.conf
Last active Oct 28, 2019

Embed
What would you like to do?
nginxでPATH_INFO
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
You can’t perform that action at this time.