Recall & Review
beginner
What is the purpose of the
default_type directive in nginx?The
default_type directive sets the MIME type that nginx uses when it cannot determine the file type of a response. It helps browsers understand how to handle the content.Click to reveal answer
beginner
What is the default value of
default_type in nginx if not explicitly set?The default value is
text/plain. This means nginx will treat unknown file types as plain text.Click to reveal answer
intermediate
How does nginx determine the MIME type of a file before using
default_type?Nginx first checks the file extension against the
mime.types file. If it finds a match, it uses that MIME type. If not, it falls back to default_type.Click to reveal answer
beginner
Show an example of setting
default_type to application/octet-stream in nginx configuration.In the nginx config file, inside the
http or server block, add:<br>default_type application/octet-stream;This tells nginx to treat unknown files as binary data.
Click to reveal answer
intermediate
Why might you want to change the
default_type from its default text/plain?Changing
default_type can improve security and user experience. For example, setting it to application/octet-stream forces downloads instead of displaying raw text, which can prevent code exposure.Click to reveal answer
What does the
default_type directive control in nginx?✗ Incorrect
The
default_type directive sets the MIME type nginx uses if it cannot detect the file type.If nginx cannot find a MIME type for a file, what is the default
default_type value it uses?✗ Incorrect
By default, nginx uses
text/plain for unknown file types.Where does nginx look first to determine a file's MIME type?
✗ Incorrect
Nginx checks the
mime.types file first to find the MIME type based on file extension.What is a common reason to set
default_type to application/octet-stream?✗ Incorrect
Setting
default_type to application/octet-stream tells browsers to download unknown files instead of displaying them.Which nginx block can contain the
default_type directive?✗ Incorrect
default_type can be set in the http or server blocks.Explain how nginx decides which MIME type to send to the client when serving a file.
Think about file extensions and fallback types.
You got /3 concepts.
Describe a scenario where changing the default_type directive improves security or user experience.
Consider what happens if unknown files are shown as plain text.
You got /3 concepts.