Hi folks,
I’ve already got an SSL certificate for the domain fito.one and would like to obtain a second SSL certificate for another domain hybrid.xyz. How do I have to set up a second Nginx server block to avoid any issue? Unfortunately, I’m not quite sure how it should be done regarding the configured port 80 and SSL 443 port.
Thank you
ubuntu@ubuntu:/etc/nginx/sites-available$ cat fito.one (working server block profile)
server {
root /var/www/fitoone;
index index.php index.html index.htm index.nginx-debian.html;
server_name fito.one www.fito.one;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/fito.one/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/fito.one/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.fito.one) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = fito.one) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name fito.one www.fito.one;
return 404; # managed by Certbot
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/fito.one/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/fito.one/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.fito.one) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = fito.one) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name fito.one www.fito.one;
return 404; # managed by Certbot
}
ubuntu@ubuntu:/etc/nginx/sites-available$ cat hybridx.xyz (current incorrect server block profile)
server {
root /var/www/hybridx;
listen 8080;
listen [::]:8080;
listen 443 ssl;
listen [::]:443 ssl;
index index.php index.html index.htm index.nginx-debian.html;
server_name hybridx.xyz www.hybridx.xyz;
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
}