From 2d135053cbd96e1e74884e4395c3163b8a39602f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Colombaro?= Date: Sun, 10 Feb 2019 20:40:50 +0100 Subject: [PATCH] Move MIME-type and charset declaration into their own conf files --- h5bp/media_types/character_encodings.conf | 32 +++++++++++++++++++++++ h5bp/media_types/media_types.conf | 18 +++++++++++++ nginx.conf | 25 +++--------------- 3 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 h5bp/media_types/character_encodings.conf create mode 100644 h5bp/media_types/media_types.conf diff --git a/h5bp/media_types/character_encodings.conf b/h5bp/media_types/character_encodings.conf new file mode 100644 index 0000000..3b3d8cd --- /dev/null +++ b/h5bp/media_types/character_encodings.conf @@ -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; diff --git a/h5bp/media_types/media_types.conf b/h5bp/media_types/media_types.conf new file mode 100644 index 0000000..b7d6f9e --- /dev/null +++ b/h5bp/media_types/media_types.conf @@ -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; diff --git a/nginx.conf b/nginx.conf index 3d83de1..e67af27 100644 --- a/nginx.conf +++ b/nginx.conf @@ -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; + include h5bp/media_types/media_types.conf; - # 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; + # 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