0
0
Nginxdevops~10 mins

Why virtual hosting serves multiple domains in Nginx - Test Your Understanding

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

Complete the code to specify the server name for a virtual host.

Nginx
server {
    listen 80;
    server_name [1];
    root /var/www/example;
}
Drag options to blanks, or click blank then click option'
A192.168.1.1
Blocalhost
Cexample.com
Ddefault_server
Attempts:
3 left
💡 Hint
Common Mistakes
Using IP address instead of domain name in server_name.
2fill in blank
medium

Complete the code to listen on port 80 for HTTP requests.

Nginx
server {
    [1] 80;
    server_name example.com;
    root /var/www/example;
}
Drag options to blanks, or click blank then click option'
Alisten
Bserver_name
Clocation
Dproxy_pass
Attempts:
3 left
💡 Hint
Common Mistakes
Using server_name instead of listen for port.
3fill in blank
hard

Fix the error in the server block to serve multiple domains.

Nginx
server {
    listen 80;
    server_name example.com [1];
    root /var/www/example;
}
Drag options to blanks, or click blank then click option'
Alocation
Blisten
Croot
Dexample.org
Attempts:
3 left
💡 Hint
Common Mistakes
Adding directives instead of domain names in server_name.
4fill in blank
hard

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

Nginx
server {
    listen 80;
    server_name [1];
    root /var/www/site1;
}

server {
    listen 80;
    server_name [2];
    root /var/www/site2;
}
Drag options to blanks, or click blank then click option'
Asite1.com
Bsite2.com
Cexample.com
Dlocalhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same domain for both server blocks.
5fill in blank
hard

Fill all three blanks to complete the virtual host configuration for multiple domains with different roots.

Nginx
server {
    listen [1];
    server_name [2];
    root [3];
}
Drag options to blanks, or click blank then click option'
A80
Bmydomain.com
C/var/www/mydomain
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 without SSL configuration.
Setting root to wrong directory.