{"id":2388,"date":"2020-11-25T06:53:59","date_gmt":"2020-11-25T06:53:59","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=2388"},"modified":"2026-01-20T05:20:28","modified_gmt":"2026-01-20T05:20:28","slug":"how-to-redirect-http-to-https-in-nginx","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/","title":{"rendered":"How To Redirect HTTP to HTTPS in NGINX"},"content":{"rendered":"\n<p>Today most websites around the world use HTTPS protocol. It is safe and secure and encrypts all data exchanged between client browser and server. Once you have configured your website to be served over HTTPS then you need to redirect HTTP to HTTPs or enforce HTTPS on your website. In this article, we will look at how to redirect HTTP to HTTPS in NGINX.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#Why_Redirect_HTTP_to_HTTPS\" >Why Redirect HTTP to HTTPS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#How_To_Redirect_HTTP_to_HTTPS_in_NGINX\" >How To Redirect HTTP to HTTPS in NGINX<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#1_Backup_NGINX_Configuration_File\" >1. Backup NGINX Configuration File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#2_Open_NGINX_configuration_file\" >2. Open NGINX configuration file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#3_Redirect_HTTP_to_HTTPS\" >3. Redirect HTTP to HTTPS<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#Redirect_all_URL_to_HTTPS\" >Redirect all URL to HTTPS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#Redirect_Specific_Website_or_Domain\" >Redirect Specific Website or Domain<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#Redirect_Specific_URL\" >Redirect Specific URL<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#4_Restart_NGINX_Server\" >4. Restart NGINX Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#5_Verify\" >5. Verify<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Redirect_HTTP_to_HTTPS\"><\/span>Why Redirect HTTP to HTTPS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>When site administrators enable HTTPS on their website, they <a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-location-to-another-domain-in-nginx\/\">redirect all HTTP pages<\/a> to be served via HTTPS. If you do not do this, then your web pages will be available via both HTTP and HTTPS. The very reason we use HTTPS to protect our website and prevent attackers from snooping into our data served over HTTP. If we do not redirect HTTP to HTTPS then it defeats the purpose of enabling SSL\/TLS on our site. Secondly, if our web pages are available over both HTTP as well HTTPS then search engines may see it as duplicate content and push down our website in search results, or even penalize it completely. So it is essential to not only setup HTTPS for our website but also redirect HTTP to HTTPS afterwards.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_To_Redirect_HTTP_to_HTTPS_in_NGINX\"><\/span>How To Redirect HTTP to HTTPS in NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the steps to redirect HTTP to HTTPS in NGINX.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Backup_NGINX_Configuration_File\"><\/span>1. Backup NGINX Configuration File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We will need to modify NGINX configuration file or virtual host file, whichever works for you. Before you do that, it is necessary to take a backup of this file so that it is easy to recover in case something goes wrong.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo cp \/etc\/nginx\/nginx.conf \/etc\/nginx\/backup-nginx.conf<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Open_NGINX_configuration_file\"><\/span>2. Open NGINX configuration file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Open terminal and run the following command to open NGINX server configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi \/etc\/nginx\/nginx.conf<\/pre>\n\n\n\n<p>If you have configured separate virtual hosts for your website (e.g <em>www.example.com<\/em>), such as \/etc\/nginx\/sites-enabled\/website.conf then open its configuration with the following command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi&nbsp;\/etc\/nginx\/sites-enabled\/website.conf<\/pre>\n\n\n\n<p>Alternatively, you can also open the default virtual host configuration file.<\/p>\n\n\n\n<pre id=\"block-d47a260a-a7b7-47b1-8b8d-d4e8e0c49519\" class=\"wp-block-preformatted\">$ sudo vi&nbsp;\/etc\/nginx\/sites-enabled\/default<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Redirect_HTTP_to_HTTPS\"><\/span>3. Redirect HTTP to HTTPS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are multiple ways to redirect HTTP to HTTPS. Before you redirect your site, it is important to understand the difference between <a href=\"https:\/\/ubiq.co\/tech-blog\/rewrite-vs-redirect-nginx\/\">URL rewrite vs redirect<\/a>. Once you know it, you can choose to proceed as shown below.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Redirect_all_URL_to_HTTPS\"><\/span>Redirect all URL to HTTPS<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Here is the server configuration if you want to redirect all URL to HTTPS.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">server {\n    listen 80 default_server;\n    server_name _;\n    return 301 https:\/\/$host$request_uri;\n}<\/pre>\n\n\n\n<p>In the above code, we specify the following<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Listen 80<\/code>: Listen to all HTTP traffic on Port 80<\/li>\n\n\n\n<li><code>Server_name _;<\/code>: Match any hostname<\/li>\n\n\n\n<li><code>Return 301<\/code>: Indicates that this is a permanent redirect<\/li>\n\n\n\n<li><code>https:\/\/$host$request_uri<\/code>: Redirect to the HTTPS version of requested URL<\/li>\n<\/ul>\n\n\n\n<p>The above configuration works for all websites hosted on your server mainly because &#8216;server_name _&#8217; listens to all hostnames in request. This will even <a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-rewrite-url-parameters-in-nginx\/\">redirect parameter-based URLs<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Redirect_Specific_Website_or_Domain\"><\/span>Redirect Specific Website or Domain<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to redirect a specific website or domain, modify server name directive as shown below. Replace example.com with your domain name.<\/p>\n\n\n\n<pre id=\"block-a5551f11-ef9b-48f0-a9a7-ed724784b2ec\" class=\"wp-block-preformatted\">server {\n    listen 80 default_server;\n    server_name example.com;\n    return 301 https:\/\/example.com$request_uri;\n}<\/pre>\n\n\n\n<p>The above config works for only example.com since we have mentioned &#8216;server_name example.com&#8217;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Redirect_Specific_URL\"><\/span>Redirect Specific URL<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to redirect only a specific URL (e.g. index.html), add a <a href=\"https:\/\/www.nginx.com\/blog\/creating-nginx-rewrite-rules\/\" target=\"_blank\" rel=\"noreferrer noopener\">rewrite<\/a> statement in its location block, as shown below. Replace example.com with your domain name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Location \/index.html {\n       rewrite ^\/index.html$ https:\/\/example.com\/index.html redirect;\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Restart_NGINX_Server\"><\/span>4. Restart NGINX Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Run the following command to check syntax of your updated config file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo nginx -t<\/pre>\n\n\n\n<p>If there are no errors, run the following command to restart NGINX server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo service nginx reload #debian\/ubuntu\n$ systemctl restart nginx #redhat\/centos<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_Verify\"><\/span>5. Verify<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Open web browser and request the HTTP version of any web page on your website. It should automatically redirect you to the HTTPS version. You can verify it by clicking on the address bar to see the full URL of final page after redirection.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Hopefully, this article will help you redirect HTTP to HTTPS in NGINX. As mentioned earlier, it is essential to setup SSL\/TLS on your website so that all web pages can be served via HTTPS. Once you do this, you need to also redirect all HTTP pages to their HTTPS version. Otherwise, your web pages will be available via both HTTP as well as HTTPS and it will defeat the purpose of encrypting your web pages using HTTPS connection.<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;makes it easy to visualize data, and monitor them in real-time dashboards.&nbsp;<a href=\"https:\/\/ubiq.co\/accounts\/register\">Try Ubiq<\/a>&nbsp;for free.<\/p>\n\n\n\n<p>Also read : <br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/\">How to Configure Basic Authentication in NGINX<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/rewrite-vs-redirect-nginx\/\">Rewrite vs Redirect in NGINX<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-create-custom-404-page-in-nginx\/\">How to Create Custom 404 Page in NGINX<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-limit-download-speed-in-nginx\/\">How to Limit Download Speed in NGINX<\/a><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to redirect HTTP to HTTPS or enforce HTTPS on your website. Here is how to redirect HTTP to HTTPS in NGINX.<\/p>\n","protected":false},"author":1,"featured_media":2407,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[33],"class_list":["post-2388","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","tag-url-redirection"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Redirect HTTP to HTTPS in NGINX - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to redirect HTTP to HTTPS or enforce HTTPS on your website. Here is how to redirect HTTP to HTTPS in NGINX.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Redirect HTTP to HTTPS in NGINX - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to redirect HTTP to HTTPS or enforce HTTPS on your website. Here is how to redirect HTTP to HTTPS in NGINX.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-25T06:53:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-20T05:20:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-redirect-http-to-https-in-nginx.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"399\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How To Redirect HTTP to HTTPS in NGINX\",\"datePublished\":\"2020-11-25T06:53:59+00:00\",\"dateModified\":\"2026-01-20T05:20:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/\"},\"wordCount\":733,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1\",\"keywords\":[\"url redirection\"],\"articleSection\":[\"Nginx\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/\",\"name\":\"How To Redirect HTTP to HTTPS in NGINX - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1\",\"datePublished\":\"2020-11-25T06:53:59+00:00\",\"dateModified\":\"2026-01-20T05:20:28+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to redirect HTTP to HTTPS or enforce HTTPS on your website. Here is how to redirect HTTP to HTTPS in NGINX.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1\",\"width\":800,\"height\":399,\"caption\":\"how to redirect http to https in nginx\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-redirect-http-to-https-in-nginx\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Redirect HTTP to HTTPS in NGINX\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Redirect HTTP to HTTPS in NGINX - Ubiq BI","description":"Sometimes you may need to redirect HTTP to HTTPS or enforce HTTPS on your website. Here is how to redirect HTTP to HTTPS in NGINX.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/","og_locale":"en_US","og_type":"article","og_title":"How To Redirect HTTP to HTTPS in NGINX - Ubiq BI","og_description":"Sometimes you may need to redirect HTTP to HTTPS or enforce HTTPS on your website. Here is how to redirect HTTP to HTTPS in NGINX.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-11-25T06:53:59+00:00","article_modified_time":"2026-01-20T05:20:28+00:00","og_image":[{"width":800,"height":399,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-redirect-http-to-https-in-nginx.png","type":"image\/png"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How To Redirect HTTP to HTTPS in NGINX","datePublished":"2020-11-25T06:53:59+00:00","dateModified":"2026-01-20T05:20:28+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/"},"wordCount":733,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1","keywords":["url redirection"],"articleSection":["Nginx"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/","name":"How To Redirect HTTP to HTTPS in NGINX - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1","datePublished":"2020-11-25T06:53:59+00:00","dateModified":"2026-01-20T05:20:28+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to redirect HTTP to HTTPS or enforce HTTPS on your website. Here is how to redirect HTTP to HTTPS in NGINX.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1","width":800,"height":399,"caption":"how to redirect http to https in nginx"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-redirect-http-to-https-in-nginx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How To Redirect HTTP to HTTPS in NGINX"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/how-to-redirect-http-to-https-in-nginx.png?fit=800%2C399&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-Cw","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=2388"}],"version-history":[{"count":31,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2388\/revisions"}],"predecessor-version":[{"id":10329,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2388\/revisions\/10329"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/2407"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=2388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=2388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=2388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}