Complete the code to specify the main configuration block in nginx.
server {
listen [1];
server_name example.com;
}The listen directive inside the server block tells nginx which port to listen on. Port 80 is the default for HTTP.
Complete the code to define the root directory for serving files.
server {
root [1];
listen 80;
}The root directive sets the directory from which nginx serves files. /usr/share/nginx/html is the common default web root.
Fix the error in the location block to correctly serve static files.
location /images/ {
alias [1];
}The alias directive requires a trailing slash when mapping a location to a directory. This ensures correct path resolution.
Fill both blanks to correctly redirect HTTP to HTTPS.
server {
listen [1];
return [2] https://$host$request_uri;
}Port 80 listens for HTTP requests. The return 301 sends a permanent redirect to HTTPS.
Fill all three blanks to define a gzip compression configuration.
gzip [1]; gzip_types [2]; gzip_min_length [3];
Enabling gzip compression with on, specifying MIME types to compress, and setting minimum length in bytes for compression.