rewrite ^ /public-service/ break;
proxy_pass https://example.com;
proxy_set_header Host $host;
httpS://public-service.com
так что нужен не listen 80;
, а listen 443 ssl;
.В качестве значения можно использовать текст, переменные и их комбинации.
Если значение поля заголовка — пустая строка, то поле вообще не будет передаваться проксируемому серверу.
map $uri $a {
default "";
~^/some_uri "Basic YWxhZGRpbjpvcGVuc2VzYW1l";
}
proxy_set_header Authorization $a;
server {
server_name neel_rl.neel;
root /var/www/neel/appRlLara/legacy;
location / {
try_files $uri /index.php$is_args$args;
location ~ \.php$ {
fastcgi_pass rl.php54:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
location /appRlLara {
root /var/www/neel/appRlLara/public;
rewrite ^/appRlLara/(.*) /$1 break;
try_files $uri /appRlLara/index.php$is_args$args;
location ~ \.php$ {
rewrite ^/appRlLara/(.*) /$1 break;
fastcgi_pass rl.php54:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
test(.*)
совпадает с test2.test/(.*)
rewrite ^/catalog/test/(.*) /catalog/test2/$1 permanent;
geo $lan {
default no;
123.224.55.2 yes;
}
map "$lan,$geoip2_data_country_code" $allowed_country {
default no;
~^yes yes;
~,UA yes;
~,BG yes;
~,RO yes;
}
rewrite ^/api/ /index.php?id=131 last;
AddType application/x-httpd-php .html .htm
if ($request_uri ~ "/index\.htm") {
return 301 /;
}
if ($request_uri ~ "^([^.?]+)\.htm") {
return 301 $1;
}
location / {
try_files $uri $uri/ $uri.htm$is_args$args;
}
location ~ \.htm {
try_files $uri =404;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location /link/ {
proxy_pass https://site1.ru/;
/link/
будет заменён на /
в итоге получится https://site1.ru/pDK9VJacsrb9bway?no=2location /link/ {
proxy_pass https://site1.ru;
proxy_set_header Host $host;
server {
listen 443 ssl http2;
server_name alias.domen.ru;
ssl_certificate ... ;
ssl_certificate_key ... ;
return 301 https://domen.ru/link/landing;
}
if
чтобы избежать зацикливания.if ($host = alias.domen.ru) {
return 301 https://domen.ru/link/landing;
}
location /sandbox/hello/ {
try_files $uri $uri/ /sandbox/hello/index.php$is_args$args;
}
server {
listen 80;
listen [::]:80;
root /var/www/example_com;
index index.html index.php;
server_name example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /sandbox/hello/ {
try_files $uri $uri/ /sandbox/hello/index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Регулярные выражения задаются либо с модификатором “~*” (для поиска совпадения без учёта регистра символов), либо с модификатором “~” (с учётом регистра).
(?<name>...)
set $test $1;
location ~ ^/(?<test>test-a-[0-9]|test-b-[0-9]) {
proxy_pass http://$test;
location = /admin/index.php {
if ($arg_route ~ "/mod2") {
rewrite ^ mod2 last;
}
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_read_timeout 60;
}
location = mod2 {
rewrite ^ /admin/index.php break;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_read_timeout 1000;
}