IP 白名单单个 php 文件与 nginx 但仍然 运行 php
IP whitelist a single php file with nginx but still run php
我有一个非常典型的 php5-fpm 设置,如下所示:
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/home/gfd-dev/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
我只想通过 ip 地址阻止 1 个文件,但是 php 不会 运行
location ^~ /script_to_hide.php {
allow 100.100.100.100;
deny all;
}
我是将整个 php$ 参数都放在两者中,还是有另一种方法来做到这一点,只告诉 php 到 运行?
nginx.conf
location ~ \.php$ {
include fastcgi_params;
}
location ^~ /secret_functions/ {
allow 100.100.100.100;
deny all;
include fastcgi_params;
}
fastcgi_params
...
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/home/gfd-dev/var/run/php5-fpm.sock;
fastcgi_index index.php;
P.S.
Nginx 遍历每个位置基于 the following logic:
location = / {
[ configuration A ]
}
location / {
[ configuration B ]
}
location /documents/ {
[ configuration C ]
}
location ^~ /images/ {
[ configuration D ]
}
location ~* \.(gif|jpg|jpeg)$ {
[ configuration E ]
}
我有一个非常典型的 php5-fpm 设置,如下所示:
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/home/gfd-dev/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
我只想通过 ip 地址阻止 1 个文件,但是 php 不会 运行
location ^~ /script_to_hide.php {
allow 100.100.100.100;
deny all;
}
我是将整个 php$ 参数都放在两者中,还是有另一种方法来做到这一点,只告诉 php 到 运行?
nginx.conf
location ~ \.php$ {
include fastcgi_params;
}
location ^~ /secret_functions/ {
allow 100.100.100.100;
deny all;
include fastcgi_params;
}
fastcgi_params
...
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/home/gfd-dev/var/run/php5-fpm.sock;
fastcgi_index index.php;
P.S.
Nginx 遍历每个位置基于 the following logic:
location = / {
[ configuration A ]
}
location / {
[ configuration B ]
}
location /documents/ {
[ configuration C ]
}
location ^~ /images/ {
[ configuration D ]
}
location ~* \.(gif|jpg|jpeg)$ {
[ configuration E ]
}