0
0
Nginxdevops~10 mins

HTTP to HTTPS redirect 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 listen on HTTP port 80.

Nginx
server {
    listen [1];
    server_name example.com;
}
Drag options to blanks, or click blank then click option'
A80
B443 ssl
C8080
D22
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 instead of 80 for HTTP.
Using an unrelated port like 22.
2fill in blank
medium

Complete the code to redirect all HTTP requests to HTTPS.

Nginx
server {
    listen 80;
    server_name example.com;

    return [1] https://$host$request_uri;
}
Drag options to blanks, or click blank then click option'
A404
B301
C200
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using 404 which means not found.
Using 200 which means OK, no redirect.
3fill in blank
hard

Fix the error in the HTTPS server block to enable SSL.

Nginx
server {
    listen 443 ssl;
    server_name example.com;

    ssl_certificate [1];
    ssl_certificate_key /etc/ssl/private/example.key;
}
Drag options to blanks, or click blank then click option'
A/etc/nginx/nginx.conf
B/etc/ssl/private/example.key
C/etc/ssl/certs/example.crt
D/var/www/html/index.html
Attempts:
3 left
💡 Hint
Common Mistakes
Using the key file path for ssl_certificate.
Using unrelated file paths.
4fill in blank
hard

Fill both blanks to complete the HTTPS server block with root and index directives.

Nginx
server {
    listen 443 ssl;
    server_name example.com;

    root [1];
    index [2];
}
Drag options to blanks, or click blank then click option'
A/var/www/html
Bindex.html
Cindex.php
D/usr/share/nginx/html
Attempts:
3 left
💡 Hint
Common Mistakes
Using a file path for root.
Using a folder path for index.
5fill in blank
hard

Fill all three blanks to complete a secure HTTPS server block with SSL protocols and ciphers.

Nginx
server {
    listen 443 ssl;
    server_name example.com;

    ssl_protocols [1];
    ssl_ciphers [2];
    ssl_prefer_server_ciphers [3];
}
Drag options to blanks, or click blank then click option'
ATLSv1.2 TLSv1.3
BHIGH:!aNULL:!MD5
Con
Doff
Attempts:
3 left
💡 Hint
Common Mistakes
Using outdated protocols like SSLv3.
Turning off server cipher preference.