Skip to content
Foxipa
Code Completion 5 Challenges

Complete the config: Nginx Config Mechanics

Fill in server blocks, location matching, maps, and includes.

Beginner ~4 min read

Challenge 1

Make / skip the whole location search with an exact match.

nginx Your answer
location  / {
    root /var/www/html;
}

Press Ctrl⌘Enter to check your answer

Challenge 2

Mark this block as the catch-all for unmatched Host headers.

nginx Your answer
server {
    listen 80 ;
    server_name _;
    return 444;
}

Press Ctrl⌘Enter to check your answer

Challenge 3

Complete the canonical WebSocket map so real upgrades keep the Connection header.

nginx Your answer
map $http_upgrade $connection_upgrade {
    default ;
    ''       close;
}

Press Ctrl⌘Enter to check your answer

Challenge 4

Load every site file dropped into conf.d.

nginx Your answer
http {
     conf.d/*.conf;
}

Press Ctrl⌘Enter to check your answer

Challenge 5

Declare the host this virtual server answers to.

nginx Your answer
server {
    listen 443 ssl;
     example.com;
}

Press Ctrl⌘Enter to check your answer