{"id":3548,"date":"2018-08-08T02:58:53","date_gmt":"2018-08-08T02:58:53","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=3548"},"modified":"2018-08-08T02:59:01","modified_gmt":"2018-08-08T02:59:01","slug":"enable-nginx-webserver-for-hsts-and-www-redirect","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect","title":{"rendered":"Enable NGinx Webserver for HSTS and www redirect"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Default nginx.conf location is in \/etc\/nginx\/<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n#Listen on http first and redirect to https:\/\/\nlisten 80 default_server;\nlisten [::]:80 default_server;\nserver_name www.domain.com domain.com;\nreturn 301 https:\/\/domain.com$request_uri;\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n#Listen on HTTPS:\/\/ then redirect non www to www\nlisten 443 ssl;\nserver_name www.domain.com;\nssl_certificate \/etc\/pki\/nginx\/star2018.pem;\nssl_certificate_key \/etc\/pki\/nginx\/wildcard.key;\nroot \/usr\/share\/nginx\/html;\nadd_header Strict-Transport-Security \"max-age=31536000; includeSubDomains; preload\";\n# Set client body size to 10M.\nclient_max_body_size 10M;\nif ($host = 'domain.com') {return 301 https:\/\/www.domain.com$request_uri;}\n# Load configuration files for the default server block.\ninclude \/etc\/nginx\/default.d\/*.conf;\n\nlocation \/ {\n        index index.php;\n        try_files $uri \/index.php$is_args$args;\n\n}\n\nerror_page 404 \/404.html;\n    location = \/40x.html {\n}\n\nerror_page 500 502 503 504 \/50x.html;\n    location = \/50x.html {\n}\nlocation ~ \\.php$ {\n\n        fastcgi_pass unix:\/var\/run\/php-fpm\/php-fpm.sock;\n\n         fastcgi_index index.php;\n         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n         include fastcgi_params;\n\n\n }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After saving this you need to restart nginx<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">sudo service nginx restart<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then use :\u00a0<a href=\"https:\/\/hstspreload.org\">https:\/\/hstspreload.org<\/a> to test<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2506,1526,2611],"class_list":["post-3548","post","type-post","status-publish","format-standard","hentry","category-research","tag-nginx","tag-redirect","tag-www"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.8 - aioseo.com -->\n\t<meta name=\"description\" content=\"You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \/etc\/nginx\/ server { #Listen on http first and redirect to https:\/\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"paris\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.8\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Welcome to Pariswells.com |\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com\" \/>\n\t\t<meta property=\"og:description\" content=\"You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \/etc\/nginx\/ server { #Listen on http first and redirect to https:\/\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2018-08-08T02:58:53+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2018-08-08T02:59:01+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com\" \/>\n\t\t<meta name=\"twitter:description\" content=\"You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \/etc\/nginx\/ server { #Listen on http first and redirect to https:\/\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#article\",\"name\":\"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com\",\"headline\":\"Enable NGinx Webserver for HSTS and www redirect\",\"author\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#organization\"},\"datePublished\":\"2018-08-08T02:58:53+00:00\",\"dateModified\":\"2018-08-08T02:59:01+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#webpage\"},\"articleSection\":\"Research, nginx, redirect, www\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pariswells.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/research#listItem\",\"name\":\"Research\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/research#listItem\",\"position\":2,\"name\":\"Research\",\"item\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/research\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#listItem\",\"name\":\"Enable NGinx Webserver for HSTS and www redirect\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#listItem\",\"position\":3,\"name\":\"Enable NGinx Webserver for HSTS and www redirect\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/category\\\/research#listItem\",\"name\":\"Research\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#organization\",\"name\":\"Welcome to Pariswells.com\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris\",\"name\":\"paris\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/93b8ee3f592ac401167f870452bd82d43de80152cd3524e2853403658ada9984?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"paris\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#webpage\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect\",\"name\":\"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com\",\"description\":\"You need to be listing on port 80 then redirect to https:\\\/\\\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \\\/etc\\\/nginx\\\/ server { #Listen on http first and redirect to https:\\\/\\\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/research\\\/enable-nginx-webserver-for-hsts-and-www-redirect#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/author\\\/paris#author\"},\"datePublished\":\"2018-08-08T02:58:53+00:00\",\"dateModified\":\"2018-08-08T02:59:01+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/\",\"name\":\"Welcome to Pariswells.com\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/pariswells.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com","description":"You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \/etc\/nginx\/ server { #Listen on http first and redirect to https:\/\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com","canonical_url":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#article","name":"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com","headline":"Enable NGinx Webserver for HSTS and www redirect","author":{"@id":"https:\/\/pariswells.com\/blog\/author\/paris#author"},"publisher":{"@id":"https:\/\/pariswells.com\/blog\/#organization"},"datePublished":"2018-08-08T02:58:53+00:00","dateModified":"2018-08-08T02:59:01+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#webpage"},"isPartOf":{"@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#webpage"},"articleSection":"Research, nginx, redirect, www"},{"@type":"BreadcrumbList","@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/pariswells.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/category\/research#listItem","name":"Research"}},{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/category\/research#listItem","position":2,"name":"Research","item":"https:\/\/pariswells.com\/blog\/category\/research","nextItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#listItem","name":"Enable NGinx Webserver for HSTS and www redirect"},"previousItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#listItem","position":3,"name":"Enable NGinx Webserver for HSTS and www redirect","previousItem":{"@type":"ListItem","@id":"https:\/\/pariswells.com\/blog\/category\/research#listItem","name":"Research"}}]},{"@type":"Organization","@id":"https:\/\/pariswells.com\/blog\/#organization","name":"Welcome to Pariswells.com","url":"https:\/\/pariswells.com\/blog\/"},{"@type":"Person","@id":"https:\/\/pariswells.com\/blog\/author\/paris#author","url":"https:\/\/pariswells.com\/blog\/author\/paris","name":"paris","image":{"@type":"ImageObject","@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/93b8ee3f592ac401167f870452bd82d43de80152cd3524e2853403658ada9984?s=96&d=mm&r=g","width":96,"height":96,"caption":"paris"}},{"@type":"WebPage","@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#webpage","url":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect","name":"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com","description":"You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \/etc\/nginx\/ server { #Listen on http first and redirect to https:\/\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/pariswells.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect#breadcrumblist"},"author":{"@id":"https:\/\/pariswells.com\/blog\/author\/paris#author"},"creator":{"@id":"https:\/\/pariswells.com\/blog\/author\/paris#author"},"datePublished":"2018-08-08T02:58:53+00:00","dateModified":"2018-08-08T02:59:01+00:00"},{"@type":"WebSite","@id":"https:\/\/pariswells.com\/blog\/#website","url":"https:\/\/pariswells.com\/blog\/","name":"Welcome to Pariswells.com","inLanguage":"en-US","publisher":{"@id":"https:\/\/pariswells.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Welcome to Pariswells.com |","og:type":"article","og:title":"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com","og:description":"You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \/etc\/nginx\/ server { #Listen on http first and redirect to https:\/\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com","og:url":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect","article:published_time":"2018-08-08T02:58:53+00:00","article:modified_time":"2018-08-08T02:59:01+00:00","twitter:card":"summary","twitter:title":"Enable NGinx Webserver for HSTS and www redirect | Welcome to Pariswells.com","twitter:description":"You need to be listing on port 80 then redirect to https:\/\/ 443 , then after you can redirect non to www ( or the other way around ) for SEO Default nginx.conf location is in \/etc\/nginx\/ server { #Listen on http first and redirect to https:\/\/ listen 80 default_server; listen [::]:80 default_server; server_name www.domain.com"},"aioseo_meta_data":{"post_id":"3548","title":null,"description":null,"keywords":null,"keyphrases":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-21 05:34:09","updated":"2022-09-15 04:23:35","primary_term":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/pariswells.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/pariswells.com\/blog\/category\/research\" title=\"Research\">Research<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tEnable NGinx Webserver for HSTS and www redirect\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/pariswells.com\/blog"},{"label":"Research","link":"https:\/\/pariswells.com\/blog\/category\/research"},{"label":"Enable NGinx Webserver for HSTS and www redirect","link":"https:\/\/pariswells.com\/blog\/research\/enable-nginx-webserver-for-hsts-and-www-redirect"}],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=3548"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3548\/revisions"}],"predecessor-version":[{"id":3550,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/3548\/revisions\/3550"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=3548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=3548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=3548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}