B
B
BonBon Slick2021-09-03 17:16:11
Nginx
BonBon Slick, 2021-09-03 17:16:11

Wildcard domain not working for subdomain?

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

https://serverfault.com/questions/249952/wildcard-...
https://stackoverflow.com/questions/12950572/nginx...
https:// serversforhackers.com/c/nginx-multi-tenancy
https://codex.so/resolving-subdomains-dynamically-...

server {
    listen 80;
    listen 443 http2 ssl reuseport;

    server_name *.local.test.net;
server_name ~^(.*)\.local.test.net;  
server_name ~^(?<subdomain>[^.]+)\.local.test.net;  
    server_name ~^(.*)\.local\.test\.net$ ;
    server_name ~^(?<subdomain>.+)\.local\.test\.net local.test.net *.local.test.net;


    ssl_certificate ...
    ssl_certificate_key ...

    root /var/www/test;
    location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
        rewrite ^(.*.php)/ $1 last;
    }


https://local.test.net/ - works
https://subdomain.local.test.net/ - error
This site can’t be reachedCheck if there is a typo in test.local.test.net.
DNS_PROBE_FINISHED_NXDOMAIN


Specified server_name formats result in an error on the subdomain

nginx logs for domain only, subdomain does not resolve at all
nginx -t says OK.
I do not understand, based on the answers and examples, it should work.

What are the reasons why it might not work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-09-03
@BonBonSlick

DNS_PROBE_FINISHED_NXDOMAIN - This browser was unable to resolve the name subdomain.local.test.net into an IP address.
Add /etc/hosts IP address corresponding to subdomain.local.test.net

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question