Nginx Configuration Essentials Practice Exam
Question 1 of 50
ssl_prefer_server_ciphers on;
TCP_NODELAY
keepalive_timeout
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
Cache-Control
Expires
expires 30d;
expires -1;
Cache-Control: no-cache
.git
.env
limit_req zone=one burst=20 nodelay;
burst
nodelay
location ~ /\. { deny all; return 404; }
server backend1.example.com:8080 weight=3 max_fails=3 fail_timeout=30s;
weight
max_fails
fail_timeout
proxy_next_upstream error timeout http_502 http_503 http_504;
http_404
auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd;
htpasswd -c /etc/nginx/.htpasswd alice
worker_connections 1024;
4096
8192
events {}
worker_processes × worker_connections
<iframe>
always
X-Frame-Options
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Content-Security-Policy
Permissions-Policy
add_header ... always;
if
proxy_cache my_cache; proxy_cache_valid 200 302 10m; proxy_cache_valid 404 1m; add_header X-Cache-Status $upstream_cache_status;
upstream backend { server 10.0.0.1:8080; server 10.0.0.2:8080; keepalive 32; }
proxy_pass http://backend;
location /helloworld.Greeter/ { grpc_pass grpc://backend; }
if ($http_x_custom = "yes") { ... }
$http_
$http_user_agent
log_format timed '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" rt=$request_time uct=$upstream_connect_time uht=$upstream_header_time urt=$upstream_response_time';
ssl_session_cache shared:SSL:10m;
certbot --nginx -d example.com -d www.example.com
/.well-known/acme-challenge/
proxy_next_upstream
root
alias
root /var/www;
/img/x.png
/var/www/img/x.png
alias /var/www/;
60s
add_header
nginx -t
nginx -T
add_header X-Frame-Options "SAMEORIGIN";
location ~ \.php$ { fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }
proxy_connect_timeout
proxy_connect_timeout 5s;
server 10.0.0.5:8080 down;
X-Accel-Redirect: /protected/file.pdf
internal
last
server
location
break
rewrite ^/old/(.*)$ /new/$1 permanent;
redirect
permanent
map
try_files
keepalive 32;
upstream
proxy_http_version 1.1; proxy_set_header Connection "";
proxy_no_cache
proxy_cache_bypass
server_name
*.example.com
www.example.*
~
open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;
=
^~
~*
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400;
75s
keepalive_timeout 30;
hstspreload.org
proxy_pass http://backend
map $http_accept_language $lang { default en; ~^fr fr; }
http
/api/
/api/users
client_body_buffer_size
TCP_CORK
tcp_nopush on;
client_body_temp_path
8k
16k
32k
stop
SIGTERM
quit
SIGQUIT
proxy_set_header Connection "";
location / { root /var/www/app/dist; try_files $uri $uri/ /index.html; } location ~* \.(?:js|css|woff2?|png|jpg|svg)$ { expires 1y; add_header Cache-Control "public, immutable"; }
Connection
Connection: close
error
error_log /var/log/nginx/error.log info;
debug
error_log ... debug;
gzip_types
gzip_types application/graphql+json application/xml;
geo $country { default ZZ; 10.0.0.0/8 US; }
tcp_nopush
two
ip_hash
sticky cookie|route|learn
@
try_files / @fallback;
error_page 404 @fallback;
autoindex on;
index
autoindex_exact_size off;
autoindex_format html;
Content-Type
upstream_cache_status
HIT
MISS
BYPASS
EXPIRED
STALE
UPDATING
REVALIDATED
gzip_static on;
file.js
file.js.gz
fastcgi_cache_path
try_files $uri $uri/ /index.php?$query_string;
proxy_cache_path
fastcgi_cache
fastcgi_cache_valid
fastcgi_cache_key "$scheme$request_method$host$request_uri"
location ~* \.html$ { add_header Cache-Control "no-store, no-cache, must-revalidate"; expires off; }
/etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
/etc/nginx/sites-enabled/
ssl_session_cache
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ { expires 1y; add_header Cache-Control "public, immutable"; }
proxy_pass
fastcgi_pass
fastcgi_param
proxy_set_header
worker_processes auto;
headers-more
proxy_hide_header X-Powered-By;
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
location = /login { limit_req zone=login burst=10 nodelay; ... }
grpc_pass
geo
ssl_stapling on; ssl_stapling_verify on; resolver 8.8.8.8 1.1.1.1 valid=300s;
certbot renew --quiet --deploy-hook "systemctl reload nginx"
listen 443 ssl; ssl_certificate /etc/ssl/certs/example.com.pem; ssl_certificate_key /etc/ssl/private/example.com.key; ssl_protocols TLSv1.2 TLSv1.3;
nginx-module-brotli
brotli on; brotli_types text/plain text/css application/javascript application/json; brotli_comp_level 6;
ssl_protocols TLSv1.2 TLSv1.3;
Server
server_tokens off;
return 301 https://example.com$request_uri;
return 404;
allow
deny
403
allow 10.0.0.0/8; deny all;
http {}
server {}
location {}
upstream {}
main
uwsgi_pass
$request_time
proxy_read_timeout
internal;
404
X-Accel-Redirect
error_page
rewrite ... last
ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 256;
worker_processes
rewrite
proxy_cache_bypass $cookie_nocache $arg_nocache; proxy_no_cache $cookie_nocache $arg_nocache;
combined
Host
Host: backend
$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"
$cookie_logged_in
resolver
resolver 1.1.1.1 8.8.8.8 valid=300s;
proxy_pass http://my.service.consul:$server_port;
include /path/to/file.conf;
proxy_pass http://backend/
/
/users
preload
Question navigator