Answer the question
In order to leave comments, you need to log in
How to put down an ssl certificate for dynamic subdomains?
I have a config for dynamic subdomains
server {
server_name *.example.com;
listen 443 ssl;
root /var/www/platforms/$host;
index index.php index.html index.htm;
location / {
root /var/www/platforms/$host;
autoindex off;
}
}
server {
server_name test.example.com;
if ($host = test.example.com){
return 301 https://$host$request_uri;
}
listen test.example.com:80;
}
server {
server_name *.example.com;
if ($host = *.example.com){
return 301 https://$host$request_uri;
}
listen *.example.com:80;
}
host not found in "*.example.com:80"
Answer the question
In order to leave comments, you need to log in
In 99% of cases, you just need to write listen 80; without any domains and IP addresses.
It almost never makes sense to specify a domain in listen. More often than not, this does not make any sense and even more likely leads to incomprehensible (for beginners) behavior.
if is not needed here either. The block should look like this:
server {
listen 80;
server_name *.example.com;
return 301 https://$host$request_uri;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question