What MIME type will nginx send for a file named data.json?
medium
A. application/json
B. text/plain
C. application/xml
D. text/html
Solution
Step 1: Check the file extension
The file is named data.json, so the extension is .json.
Step 2: Match extension to MIME type in config
The config maps .json to application/json.
Final Answer:
application/json -> Option A
Quick Check:
.json = application/json [OK]
Hint: Match file extension to MIME type in 'types' block [OK]
Common Mistakes:
Confusing .json with .xml MIME type
Assuming default text/plain without config
Ignoring the dot before extension
4. You added this to your nginx config:
types {
.txt text/plain
.md text/markdown;
}
Why might nginx fail to start?
medium
A. MIME types cannot include 'text/markdown'
B. Wrong block name 'types' instead of 'mime_types'
C. File extensions must not have dots
D. Missing semicolon after .txt MIME type
Solution
Step 1: Check syntax for each MIME type line
Each line must end with a semicolon; the line for .txt is missing it.
Step 2: Validate block name and extensions
The block name types is correct, and dots before extensions are required.
Final Answer:
Missing semicolon after .txt MIME type -> Option D
Quick Check:
Every MIME type line ends with semicolon [OK]
Hint: Check semicolons after each MIME type line [OK]
Common Mistakes:
Forgetting semicolon at line end
Changing 'types' block name incorrectly
Removing dots before extensions
5. You want nginx to serve a new file type .abc with MIME type application/x-abc. Which config snippet correctly adds this without removing existing types?
hard
A. mime_types { .abc application/x-abc; }
B. types { .abc application/x-abc; }
C. types { include mime.types; .abc application/x-abc; }
D. types { .abc = application/x-abc; }
Solution
Step 1: Preserve existing MIME types
To keep existing types, include the default mime.types file inside the types block.
Step 2: Add new MIME type after include
After including existing types, add .abc application/x-abc; to extend the list.
Final Answer:
types { include mime.types; .abc application/x-abc; } -> Option C
Quick Check:
Include existing types then add new ones [OK]
Hint: Include mime.types before adding new MIME types [OK]
Common Mistakes:
Overwriting existing types by not including mime.types