0
0
Nginxdevops~5 mins

Default type handling in Nginx - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AThe default server port
BThe maximum file upload size
CThe default root directory
DThe MIME type used when file type is unknown
If nginx cannot find a MIME type for a file, what is the default default_type value it uses?
Aapplication/json
Btext/plain
Ctext/html
Dapplication/octet-stream
Where does nginx look first to determine a file's MIME type?
Adefault_type directive
Berror_page directive
Cmime.types file
Dserver_name directive
What is a common reason to set default_type to application/octet-stream?
ATo force file downloads
BTo display files as plain text
CTo enable caching
DTo increase server speed
Which nginx block can contain the default_type directive?
Ahttp or server block
Blocation block only
Cevents block
Dupstream block
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.