R
R
RokeAlvo2020-11-25 09:02:14
Nginx
RokeAlvo, 2020-11-25 09:02:14

How to use variables from server_name nginx?

the essence of the problem there are several sites isa.site.com, isb.site.com ... isz.site.com
there are local folders /home/user/sites/a, /home/user/sites/b etc.. .in
nginx config

server {
  listen 443;
  server_name ~^is(?<subdomain_suffix>.+?)\.(site\.com.+)$;
  set $root /home/user/sites/$subdomain_suffix;
  root $root;
  ...
}


but all requests like isa.site.com go to the local /home/user/sites directory, as if $subdomain_suffix==""

What's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-11-25
@shambler81

do not invent the wheel
1. you have 3 sites, make three configs as expected, do not reinvent the wheel, especially from scratch.
2. You have 300 sites, here a template engine or a web muzzle will help you, in fact, all this is also in bulk. and free of charge and of good quality, why twist the crutches, again, it is not clear.
3. You have dynamic domain names, but here it is reported to manage the core of the project and here it is strictly individual.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question