map $args $replace {
volatile;
default $args;
~^(.*)HELLO(.*) "$1NO$2";
}
server {
location /server/load.php {
rewrite ^ $uri?$replace?;
rewrite ^ $uri?$replace? break;
proxy_pass localhost:88;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
}
Запросы с пустым значением ключа не учитываются.
map $arg_method $var {
default "";
"phone" $binary_remote_addr;
}
limit_req_zone $var zone=perip:10m rate=5r/s;
server {
rewrite ^/([^/]+)/([^/]+)/([^/.]+)$ /index.php?get1=$1&get2=$2&get3=$3;
rewrite ^/([^/]+)/([^/.]+)$ /index.php?get1=$1&get2=$2;
rewrite ^/([^/.]+)$ /index.php?get1=$1;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\. {
deny all;
}
/\.
ловит любые адреса где после слэша идёт точка.location ~ \.php$ {
include fastcgi_params;
fastcgi_param REQUEST_URI $request_uri;
map $request_uri $_fix_request_uri {
default $request_uri;
~^/mcs/users(/graphql/.*)$ $1;
}
server {
location ~ \.php$ {
include fastcgi_params;
fastcgi_param REQUEST_URI $_fix_request_uri;
server {
listen 80;
server_name example.com www.example.com;
root /var/www/example.com;
}
server {
listen 80;
server_name *.example.com;
root /var/www/$host;
}
server {
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*) /index.php?altum=$1;
}
location ~ \.php$ {
...
}
server {
location ~ \.php$ {
...
}
location ~ ^/(.*) {
try_files $uri $uri/ /index.php?altum=$1&$args;
}
map $uri $_uri {
~^/(.*) $1;
}
server {
location / {
try_files $uri $uri/ /index.php?altum=$_uri&$args;
}
location ~ \.php$ {
...
}
map "$remote_addr;$args" $var {
default 0;
"~^94\.143\.197\.26;full_slug=[^&]*&cat=-1&page=\d*$" 1;
}
server {
location = /seek {
if ($var) {
return 403;
}
rewrite ^ /index.php;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location /client/dev {
alias /var/www/site.ru/build;
try_files $uri /index.html =404;
}
location /client/dev {
alias /var/www/site.ru/build;
try_files $uri /client/dev/index.html;
}
Необходимо иметь в виду, что при использовании индексного файла делается внутреннее перенаправление и запрос может быть обработан уже в другом location’е.
index index.html;
нужен try_files.location = / {
try_files /index.html =404;
}
location / {
proxy_pass ...;
}
location = / {
rewrite ^ /index.html break;
}
location / {
proxy_pass ...;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://95.216.144.51:8080;
location @fallback {
proxy_pass http://95.216.144.51:8080;
}
location ~ ^/id/(.+) {
return 301 /?id=$1;
}
rewrite ^/id/(.+) /?id=$1 permanent;
rewrite ^/id/(.+) /?id=$1 last;
$url = '/internal_redirect/http://domain.com/?test=123&test2=234';
header("X-Accel-Redirect: " . $url);
location ~ ^/internal_redirect/(?<url>.+) {
internal;
proxy_pass $url$is_args$args;
}