Nginx configure server_name regular ~ ^ (? < user >. +)\ .example\ .net $problem

nginx configuration server_name regular
server_name ~ ^ (? < user >. +)\ .example\ .net $;
where ? < user > . Is it a whole? What does it mean? Does it mean to get the value of the variable user ? How did this variable come from? Or is user a built-in variable in nginx?

Mar.02,2022

(? < user >. +) is a capture group , ? < user > does not participate in the matching, that is, the matching content of the expression (? < user >. +) is consistent with the expression . + , the difference is that the matching content of the former is saved to the variable user .

it is recommended to supplement the knowledge of the regular capture group (some articles are also called capture elements). If a large number of related articles are found on the Internet, the links will not be posted here

.

example

nginx.conf configuration

worker_processes 4;
error_log logs/nginx_error.log crit;
events {
    worker_connections  1024;
}
http {
    log_format  main '$resource - $id';

    server
    {
      listen 8080;
      server_name localhost;
      index index.html;
      location ~ /(?<resource>\w+)/(?<id>[0-9]+)/ {
            access_log  logs/access.log  main;
            root D:/test;
        }
    }
}

the log content appears in

Previous: Automatic deployment using phpstorm

Next: Does git submodule add also support sparse checkout?

Menu