Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

Configure multiple SSL certificates on the same IP with Nginx

Leer en espanol
Configure multiple SSL certificates on the same IP with Nginx

Table of contents

To do this we will vary ===

In the previous entry we saw how to configure a certificate in both nginx and Apache, this time we are going to configure two vhosts with the same certificate and IP address.

To do this we will vary the port through which it provides service

nginx
server {
listen 80;
listen   443 ssl;
server_name  pre-red-orbita.com;
access_log logs/redorbita-access.log combined;
ssl on;
ssl_certificate /etc/nginx/certs/redorbita.crt;
ssl_certificate_key /etc/nginx/certs/redorbita.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;        error_log logs/bbvaopen4u-error.log;
root /var/www/;
index index.php index.html index.htm;
location / {
root /var/www/preredorbita;
index index.php index.html index.htm;
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
location ~ \.php$ {
proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
# redirect server error pages to the static page /40x.html
#
error_page  404              /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /51x.html {
}
}
server {
listen 81;
listen   444 ssl;
server_name  pre2-red-orbita.com;
access_log logs/redorbita2-access.log combined;
ssl_certificate /etc/nginx/certs/redorbita.crt;
ssl_certificate_key /etc/nginx/certs/redorbita.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;        error_log logs/bbvaopen4u-error.log;
root /var/www/;
index index.php index.html index.htm;
location / {
root /var/www/pre2redorbita;
index index.php index.html index.htm;
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
location ~ \.php$ {
proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
# redirect server error pages to the static page /40x.html
#
error_page  404              /404.html;
location = /40x.html {
}
# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /51x.html {
}
}

All the best.

:wq!

Comments