0
0
Nginxdevops~10 mins

SNI for multiple SSL certificates in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the SSL certificate file for the server block.

Nginx
server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate [1];
}
Drag options to blanks, or click blank then click option'
A/etc/nginx/ssl/example.com.key
B/etc/nginx/ssl/example.com.crt
C/etc/nginx/nginx.conf
D/var/www/html/index.html
Attempts:
3 left
💡 Hint
Common Mistakes
Using the private key file path instead of the certificate file.
Using unrelated file paths like configuration or HTML files.
2fill in blank
medium

Complete the code to specify the SSL private key file for the server block.

Nginx
server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate /etc/nginx/ssl/example.com.crt;
    ssl_certificate_key [1];
}
Drag options to blanks, or click blank then click option'
A/etc/nginx/ssl/example.com.crt
B/etc/nginx/nginx.conf
C/etc/nginx/ssl/dhparam.pem
D/etc/nginx/ssl/example.com.key
Attempts:
3 left
💡 Hint
Common Mistakes
Using the certificate file path instead of the private key file.
Using unrelated files like Diffie-Hellman parameters or config files.
3fill in blank
hard

Fix the error in the listen directive to enable SNI for multiple SSL certificates.

Nginx
server {
    listen [1];
    server_name site1.example.com;
    ssl_certificate /etc/nginx/ssl/site1.crt;
    ssl_certificate_key /etc/nginx/ssl/site1.key;
}
Drag options to blanks, or click blank then click option'
A443 ssl default_server
B443 ssl
C443 ssl http2
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting 'ssl' in the listen directive causes SSL not to work.
Using 'default_server' when not needed can cause conflicts.
4fill in blank
hard

Fill both blanks to configure two server blocks for different domains using SNI.

Nginx
server {
    listen 443 ssl http2 [1];
    server_name site1.example.com;
    ssl_certificate /etc/nginx/ssl/site1.crt;
    ssl_certificate_key /etc/nginx/ssl/site1.key;
}

server {
    listen 443 ssl http2 [2];
    server_name site2.example.com;
    ssl_certificate /etc/nginx/ssl/site2.crt;
    ssl_certificate_key /etc/nginx/ssl/site2.key;
}
Drag options to blanks, or click blank then click option'
Adefault_server
Breuseport
Cipv6only=on
Dproxy_protocol
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default_server' in both blocks causes conflicts.
Omitting 'reuseport' can cause socket binding errors.
5fill in blank
hard

Fill all three blanks to create a map for selecting SSL certificates based on the server name.

Nginx
map $ssl_server_name $ssl_cert {
    default [1];
    site1.example.com [2];
    site2.example.com [3];
}

map $ssl_server_name $ssl_key {
    default /etc/nginx/ssl/default.key;
    site1.example.com /etc/nginx/ssl/site1.key;
    site2.example.com /etc/nginx/ssl/site2.key;
}

server {
    listen 443 ssl http2;
    ssl_certificate $ssl_cert;
    ssl_certificate_key $ssl_key;
}
Drag options to blanks, or click blank then click option'
A/etc/nginx/ssl/default.crt
B/etc/nginx/ssl/site1.crt
C/etc/nginx/ssl/site2.crt
D/etc/nginx/ssl/site3.crt
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same certificate for all domains defeats the purpose of SNI.
Not setting a default certificate can cause SSL errors.