location ^~ /uploads/thumbs/ {
root /home/admin/web/site-b.com/public_html;
try_files $uri @proxy;
}
location @proxy {
proxy_pass http://11.22.33.44:80$uri;
proxy_set_header Host site-a.com;
}
location /_next/static/ {
alias /var/www/promo/nextjs-coupon/.next/static;
^~
и в alias добавить /
location ^~ /_next/static/ {
alias /var/www/promo/nextjs-coupon/.next/static/;
fastcgi_param APP_SETTINGS app-settings-12;
fastcgi_param API_ENDPOINT app-endpoint-outer;
fastcgi_param USE_SHOTLINKS false;
fastcgi_param PHP_VALUE auto_prepend_file=$document_root/file.php;
server_name site.ru; server_name www.site.ru; rewrite ^/(.*)/$ /$1 permanent;
if ($request_uri ~ "\.html\?selected_section=discussion") {
return 301 $uri;
}
location = /abcd/auth/sign-in {
proxy_pass http://198.12.123.42.23/auth/sign-in;
}
location ~ ^/abcd/auth/sign-in$ {
rewrite ^ /auth/sign-in break;
proxy_pass http://198.12.123.42.23;
}
location ~ ^/abcd(/auth/sign-in)$ {
proxy_pass http://198.12.123.42.23$1;
}
href="styles/impact/css/site.css"
./e-voting-ui-pl/console
/e-voting-ui-pl/console/
location ^~ /e-voting-ui-pl/console/ {
proxy_pass http://p01qr01.test.local:8161/;
}
location /foo/bar/ {
proxy_pass http://127.0.0.1:3000/;
}
location /foo/bar {
rewrite ^/foo/bar/?(.*) /$1 break;
proxy_pass http://127.0.0.1:3000;
}
/ja -> /jp
/ja/ -> /jp/
/ja/page -> /jp/page
server {
rewrite ^/ja($|/.*) /jp$1 permanent;
Если alias используется внутри location’а, заданного регулярным выражением, то регулярное выражение должно содержать выделения, а сам alias — ссылки на эти выделения
location ~* ^/static/\d+/(.+\.css)$ {
alias /path/to/static/$1;
}
location ~* ^/(static)/\d+/(.+\.css)$ {
alias %hostdir%/$1/$2;
}
location ~* ^.+\.(css...
. root /www/pcl.col;
location / {
try_files $uri /index.php$is_args$args;
}
location /project-1 {
try_files $uri /project-1/index.php;
}
location /project-2 {
try_files $uri /project-2/index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
/path?query
/path
, а GET параметры следует искать в $args.if ($request_uri ~ "/\?[a-z]{9}") {
return 403;
}
/upload/file.jpg
попадает в location ~* ^/(upload|bitrix/images|bitrix/tmp)
. if
и добавление try_files
не даст нужного результата.location ~* ^/(upload|bitrix/images|bitrix/tmp) {
if ( $upstream_http_x_accel_redirect = '' ) {
expires 30d;
}
try_files $uri /bitrix/images/main/blank.gif;
}
if
или вместо try_files
использовать error_page
location ~* ^/(upload|bitrix/images|bitrix/tmp) {
if ( $upstream_http_x_accel_redirect = '' ) {
expires 30d;
}
error_page 404 =200 /bitrix/images/main/blank.gif;
}
/dir/1
, а в try_files нужно передать только часть /dir/
.(/[a-z-]+/)
и в $1 получаем нужное значение.location ~ "^(/[a-z-]+/)(1\d|[1-9])$" {
index /category.php;
try_files $1/ =404;
}
location ~ [^/]\.php(/|$) {
...
fastcgi_param SCRIPT_FILENAME "/Users/yarovikov/.composer/vendor/laravel/valet/server.php";
...
}
location ~* ^/wp-content/uploads/.+?\.(rar|zip|7z)$ {
rewrite (.+) /wp-content/themes/test-theme/inc/nginx-file-request.php?path=$1 break;
root /Users/yarovikov/Sites/localhost/test-site;
fastcgi_pass "unix:/Users/yarovikov/.config/valet/valet.sock";
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}