Daybreaker
Daybreaker

Reputation: 1047

Wildcard subdomain in Ngnix

I want to configure Nginx as a reverse proxy. But i want to configure it only for a part of subdomain, which is dyanamic. I tried with * and it didnt work. Can anyone help me here.

server {
    listen 80;
    server_name  (dynamic_part)-clientapp.mydomain.com;

    location / {
    }
}

Thanks in advance.

Upvotes: 0

Views: 82

Answers (1)

the reason the * is not working:

A wildcard name may contain an asterisk only on the name’s start or end, and only on a dot border. The names “www..example.org” and “w.example.org” are invalid. However, these names can be specified using regular expressions, for example, “~^www..+.example.org$” and “~^w..example.org$”. An asterisk can match several name parts. The name “.example.org” matches not only www.example.org but www.sub.example.org as well.

http://nginx.org/en/docs/http/server_names.html

Did you try it with a regex, like as example:

server {
    listen 80;
    server_name  ~(.*)-clientapp\.mydomain\.com;


    location / {
    }
}

Upvotes: 1

Related Questions