0
0
Nginxdevops~20 mins

MIME types configuration in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
MIME Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Identify MIME type served by Nginx
Given the following Nginx configuration snippet, what MIME type will Nginx serve for a file named example.svg?
Nginx
types {
    text/html  html;
    image/svg+xml  svg;
    application/javascript  js;
}

location / {
    root /var/www/html;
}
Aapplication/octet-stream
Btext/html
Capplication/javascript
Dimage/svg+xml
Attempts:
2 left
💡 Hint
Check the MIME type associated with the .svg extension in the types block.
Configuration
intermediate
2:00remaining
Correct MIME type for JSON files
Which configuration snippet correctly sets the MIME type for files with the .json extension to application/json in Nginx?
A
types {
    application/json json;
}
B
types {
    text/json json;
}
C
types {
    application/javascript json;
}
D
types {
    application/json js;
}
Attempts:
2 left
💡 Hint
The MIME type must be application/json and the extension json.
Troubleshoot
advanced
2:00remaining
Why is Nginx serving wrong MIME type?
You configured Nginx to serve .woff2 files with MIME type font/woff2 but browsers still treat them as application/octet-stream. What is the most likely cause?
AThe <code>mime.types</code> file is not included in the main configuration.
BThe <code>types</code> block is missing the <code>woff2</code> extension mapping.
CThe <code>default_type</code> directive is set to <code>application/octet-stream</code> and overrides types.
DThe <code>root</code> directive is incorrect, causing files not to be found.
Attempts:
2 left
💡 Hint
Check if the standard MIME types file is loaded by Nginx.
🔀 Workflow
advanced
2:00remaining
Order of MIME type resolution in Nginx
In what order does Nginx determine the MIME type for a requested file?
ACheck <code>types</code> block in current context → Use <code>default_type</code> if no match → Check <code>mime.types</code> file
BCheck <code>types</code> block in current context → Check <code>mime.types</code> file → Use <code>default_type</code> if no match
CCheck <code>mime.types</code> file → Check <code>types</code> block in current context → Use <code>default_type</code> if no match
DUse <code>default_type</code> first → Check <code>types</code> block → Check <code>mime.types</code> file
Attempts:
2 left
💡 Hint
Nginx first looks at local types, then global mime.types, then default.
Best Practice
expert
3:00remaining
Best practice for custom MIME types in Nginx
What is the best practice to add a custom MIME type for a new file extension .abc without modifying the default mime.types file?
AAdd a <code>types</code> block with the new mapping inside the <code>http</code> block in your main config.
BDirectly edit the <code>mime.types</code> file to add the new extension and reload Nginx.
CCreate a separate file with the new MIME type and include it in the main config using the <code>include</code> directive.
DUse the <code>default_type</code> directive to set the MIME type for .abc files.
Attempts:
2 left
💡 Hint
Avoid editing default files; use includes for customizations.