Answer the question
In order to leave comments, you need to log in
How to set up nginx for multiple addresses and domains?
The server has several ip-addresses and domains with which it can work. How to configure nginx so that for each address or domain it gives its own tls certificate?
server {
listen *:80;
# listen 443 http3 reuseport;
listen *:443 ssl;
root /var/www/trainzcity.myftp.org/html;
index index.html index.htm index.nginx-debian.html;
server_name trainzcity.myftp.org;
ssl_certificate /etc/nginx/certs/0001_chain.pem;
ssl_certificate_key /etc/nginx/certs/key-384r1.key;
ssl_protocols TLSv1.3;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen *:80;
# listen 443 http3 reuseport;
listen *:443 ssl;
root /var/www/trainzcity.myftp.org/html;
index index.html index.htm index.nginx-debian.html;
server_name nix-adserver nix-adserver.trainzcity.myftp.org;
ssl_certificate /path/to/pki/nix-adserver.trainzcity.myftp.org.crt;
ssl_certificate_key /path/to/pki/nix-adserver.trainzcity.myftp.org.key;
ssl_protocols TLSv1.3;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80;
# listen 192.168.10.2:443 http3 reuseport;
listen 443 ssl;
root /var/www/trainzcity.myftp.org/html;
index index.html index.htm index.nginx-debian.html;
server_name 192.168.10.2;
ssl_certificate /path/to/pki/trainzcity.myftp.org.crt;
ssl_certificate_key /path/to/pki/trainzcity.myftp.org.key;
ssl_protocols TLSv1.3;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen *:80;
# listen 443 http3 reuseport;
listen *:443 ssl;
root /var/www/trainzcity.myftp.org/html;
index index.html index.htm index.nginx-debian.html;
server_name 1.1.1.1;
ssl_certificate /path/to/pki/rainzcity.myftp.org.crt;
ssl_certificate_key /path/to/pki/trainzcity.myftp.org.key;
ssl_protocols TLSv1.3;
location / {
try_files $uri $uri/ =404;
}
}
Answer the question
In order to leave comments, you need to log in
This will suffice:
server {
listen 80;
# listen 443 http3 reuseport;
listen 443 ssl;
root /var/www/trainzcity.myftp.org/html;
index index.html index.htm index.nginx-debian.html;
server_name trainzcity.myftp.org;
ssl_certificate /etc/nginx/certs/0001_chain.pem;
ssl_certificate_key /etc/nginx/certs/key-384r1.key;
ssl_protocols TLSv1.3;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 80;
# listen 443 http3 reuseport;
listen 443 ssl;
root /var/www/trainzcity.myftp.org/html;
index index.html index.htm index.nginx-debian.html;
server_name nix-adserver.trainzcity.myftp.org;
ssl_certificate /path/to/pki/nix-adserver.trainzcity.myftp.org.crt;
ssl_certificate_key /path/to/pki/nix-adserver.trainzcity.myftp.org.key;
ssl_protocols TLSv1.3;
location / {
try_files $uri $uri/ =404;
}
}
listen 80
already listen 443 ssl
allow Nginx to listen on all interfaces. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question