Skip to content

Commit

Permalink
Move MIME-type and charset declaration into their own conf files
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoColomb committed Feb 10, 2019
1 parent 452b630 commit 2d13505
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 23 deletions.
32 changes: 32 additions & 0 deletions h5bp/media_types/character_encodings.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ----------------------------------------------------------------------
# | Character encodings |
# ----------------------------------------------------------------------

# Serve all resources labeled as `text/html` or `text/plain`
# with the media type `charset` parameter set to `UTF-8`.
#
# https://nginx.org/en/docs/http/ngx_http_charset_module.html#charset

charset utf-8;

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Update charset_types to match updated mime.types.
# text/html is always included by charset module.
# Default: text/html text/xml text/plain text/vnd.wap.wml application/javascript application/rss+xml
#
# https://nginx.org/en/docs/http/ngx_http_charset_module.html#charset_types

charset_types
text/css
text/plain
text/vnd.wap.wml
text/javascript
text/markdown
text/calendar
text/x-component
text/vcard
text/cache-manifest
text/vtt
application/json
application/manifest+json;
18 changes: 18 additions & 0 deletions h5bp/media_types/media_types.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ----------------------------------------------------------------------
# | Media types |
# ----------------------------------------------------------------------

# Serve resources with the proper media types (f.k.a. MIME types).
#
# https://www.iana.org/assignments/media-types/media-types.xhtml
# https://nginx.org/en/docs/http/ngx_http_core_module.html#types

include mime.types;

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Default: text/plain
#
# https://nginx.org/en/docs/http/ngx_http_core_module.html#default_type

default_type application/octet-stream;
27 changes: 4 additions & 23 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,10 @@ http {
include h5bp/security/server_software_information.conf;

# Specify MIME types for files.
# https://nginx.org/en/docs/http/ngx_http_core_module.html#types
include mime.types;

# Default: text/plain
# https://nginx.org/en/docs/http/ngx_http_core_module.html#default_type
default_type application/octet-stream;

# Specify a charset
# https://nginx.org/en/docs/http/ngx_http_charset_module.html#charset
charset utf-8;

# Update charset_types to match updated mime.types.
# text/html is always included by charset module.
# Default: text/html text/xml text/plain text/vnd.wap.wml application/javascript application/rss+xml
# https://nginx.org/en/docs/http/ngx_http_charset_module.html#charset_types
charset_types
text/css
text/plain
text/vnd.wap.wml
text/javascript
application/json
application/rss+xml
application/xml;
include h5bp/media_types/media_types.conf;

# Set character encodings.
include h5bp/media_types/character_encodings.conf;

# Include $http_x_forwarded_for within default format used in log files
# https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
Expand Down

0 comments on commit 2d13505

Please sign in to comment.