{"id":2362,"date":"2020-11-25T06:05:24","date_gmt":"2020-11-25T06:05:24","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=2362"},"modified":"2025-08-28T05:03:46","modified_gmt":"2025-08-28T05:03:46","slug":"how-to-configure-basic-authentication-in-nginx","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/","title":{"rendered":"How To Configure Basic Authentication in NGINX"},"content":{"rendered":"\n<p>NGINX allows you to configure basic HTTP authentication on your website which allows you to restrict access to one or more pages on your website using a simple username\/password. You can use this method to secure http, server or even location blocks. You can use it to secure virtual hosts, websites, or sensitive pages of your website such as admin pages. In this article, we will look at how to configure basic authentication 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-configure-basic-authentication-in-nginx\/#What_is_Authentication_in_NGINX\" >What is Authentication in NGINX<\/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-configure-basic-authentication-in-nginx\/#Why_Do_You_Need_Basic_Authentication\" >Why Do You Need Basic Authentication<\/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-configure-basic-authentication-in-nginx\/#How_To_Configure_Basic_Authentication_in_NGINX\" >How To Configure Basic Authentication in NGINX<\/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-configure-basic-authentication-in-nginx\/#1_Install_Apache_Utils\" >1. Install Apache Utils<\/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-configure-basic-authentication-in-nginx\/#2_Create_UserPassword\" >2. Create User\/Password<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#3_Backup_Files\" >3. Backup Files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#4_Open_NGINX_configuration_file\" >4. 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-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#5_Password_Protect_NGINX\" >5. Password Protect NGINX<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#Password_Protect_All_Servers\" >Password Protect All Servers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#Password_Protect_Single_website_or_server\" >Password Protect Single website or server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#Password_protect_a_directory\" >Password protect a directory<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#Protect_Single_URL\" >Protect Single URL<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#6_Restart_NGINX_Server\" >6. Restart NGINX Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#7_Verify_basic_authentication\" >7. Verify basic authentication<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_Authentication_in_NGINX\"><\/span>What is Authentication in NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>By default, when you run a site on NGINX, all users can access all its pages unless their access is controlled. Many administrators use firewall rules or Allow\/Deny server directives to <a href=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-directory-and-subdirectories\/\">restrict access<\/a> to one or more web pages on their site, in case it contains sensitive information. But anyone can access these pages from those IP addresses that are allowed access. So how to add an extra layer of security? NGINX allows you to password protect one or more web pages on your website.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Do_You_Need_Basic_Authentication\"><\/span>Why Do You Need Basic Authentication<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>By default, all web pages on your website are publicly accessible via NGINX. Often website administrators may need to <a href=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/\">protect web pages<\/a> with sensitive information from public access. In such cases, it is advisable to add an extra layer of security by enabling basic authentication for those web pages. Once this is done, when a user requests access to web page with basic authentication, they will be asked for username &amp; password to proceed further. This basic authentication allows site admins to selectively control access to certain critical web pages, without affecting other pages. Also, it does not require any coding so they do not have to depend on the web development team.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_To_Configure_Basic_Authentication_in_NGINX\"><\/span>How To Configure Basic Authentication in NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the steps to configure basic authentication in NGINX.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Install_Apache_Utils\"><\/span>1. Install Apache Utils<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We need to use <em>htpasswd<\/em> utility to set up basic authentication. For that, we need to install apache2-utils&nbsp;or&nbsp;httpd-tools. Open terminal and run the following command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># yum install httpd-tools [RHEL\/CentOS] \n$ sudo apt install apache2-utils [Debian\/Ubuntu]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Create_UserPassword\"><\/span>2. Create User\/Password<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Next, run <em>htpasswd<\/em> command to create a user that will be given access to your website.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># htpasswd -c \/etc\/nginx\/conf.d\/.htpasswd developer<\/pre>\n\n\n\n<p>We use -c option to specify password file location. When you press enter, you will be prompted for a password.<\/p>\n\n\n\n<p>For example, when we create another user, we don&#8217;t specify password file location.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># htpasswd \/etc\/nginx\/conf.d\/.htpasswd developer2<\/pre>\n\n\n\n<p>This file contains a list of user credentials who will be allowed access to your password protected web pages. By modifying its contents, you can control which user can access your web pages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Backup_Files\"><\/span>3. Backup Files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We need to modify NGINX configuration file or virtual host file, whichever you have access to. So it is essential to take a backup of these files before you edit it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo cp \/etc\/nginx\/nginx.conf \/etc\/nginx\/backup-nginx.conf<br>OR<br>$ sudo cp $ sudo vi&nbsp;\/etc\/nginx\/sites-enabled\/website.conf \/etc\/nginx\/sites-enabled\/backup-website.conf<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Open_NGINX_configuration_file\"><\/span>4. 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=\"5_Password_Protect_NGINX\"><\/span>5. Password Protect NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In order to password protect your website, or certain web pages, we need to use <em>auth_basic<\/em> and <em>auth_basic_user_file<\/em> directives in NGINX server configuration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Password_Protect_All_Servers\"><\/span>Password Protect All Servers<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>For example, if you want to configure basic authentication for all virtual hosts (an entire http block), add the above two directives as shown below in http block.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">http{\n   ...\n   auth_basic \"Restricted Access!\"; \n   auth_basic_user_file \/etc\/nginx\/conf.d\/.htpasswd;\n   ...\n}<\/pre>\n\n\n\n<p>In the above code, we specify the path of password file in <em>auth_basic_user_file<\/em> directive and message to be displayed in <em>auth_basic<\/em> directive.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Password_Protect_Single_website_or_server\"><\/span>Password Protect Single website or server<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Similarly, here&#8217;s the code to protect <em>server<\/em> block, that is, implement basic authentication for website or domain.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">server{\n    ...\n    auth_basic \"Restricted Access!\";\n    auth_basic_user_file \/etc\/nginx\/conf.d\/.htpasswd;\n    ...\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Password_protect_a_directory\"><\/span>Password protect a directory<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can also configure basic authentication for specific web pages\/subdirectories (e.g \/admin) by adding <em>auth_basic<\/em> and <em>auth_basic_user_file<\/em> directives in a location block.<\/p>\n\n\n\n<pre id=\"block-83d3cdd4-ec9a-4640-8c41-34d89cb9ac6b\" class=\"wp-block-preformatted\">location \/admin\/ {\n    ...\n    auth_basic \"Restricted Access!\";\n    auth_basic_user_file \/etc\/nginx\/conf.d\/.htpasswd;\n    ...\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Protect_Single_URL\"><\/span>Protect Single URL<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can also do this for a single URL. Just add the auth_basic and auth_basic_user_file directive for location block of URL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">location \/login.php {<br>    ...<br>    auth_basic \"Restricted Access!\";<br>    auth_basic_user_file \/etc\/nginx\/conf.d\/.htpasswd;<br>    ...<br>}<\/pre>\n\n\n\n<p>Please note, you do not need to use the same password file for every auth_basic_user_file directive. you can always create multiple password files in step #2. Once you do this, you can pick and choose the appropriate file for each auth_basic_user_file. This provides a powerful way to control user access, without any coding or updating firewall rules.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_Restart_NGINX_Server\"><\/span>6. 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=\"7_Verify_basic_authentication\"><\/span>7. Verify basic authentication<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Open browser and visit the URL (e.g www.example.com\/admin) that you have protected. You should see an authentication screen as the one below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"730\" height=\"431\" src=\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/Nginx-Basic-Authentication.png?resize=730%2C431&#038;ssl=1\" alt=\"\" class=\"wp-image-2382\" srcset=\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/Nginx-Basic-Authentication.png?w=793&amp;ssl=1 793w, https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/Nginx-Basic-Authentication.png?resize=768%2C453&amp;ssl=1 768w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/figure>\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>In this article, we have learnt how to enable basic authentication in NGINX server. You can use this to configure password protection for one or more web pages on your site. It is a very useful way to block unauthorized access on your website. It does not require any coding. Once you have enabled basic authentication, you can easily add, remove or modify user credentials in .htpasswd file and control which users have access to your web pages. You can create multiple password files to compartmentalize users and choose the appropriate file for each auth_basic_user_file server directive. This makes it easy to manage user access without any coding or firewall rules.<\/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-enable-nginx-gzip-compression\/\">How to Enable GZIP Compression 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><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\/rewrite-vs-redirect-nginx\/\">Redirect vs Rewrite in NGINX<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>NGINX basic authentication allows you to protect servers, websites, virtual hosts and web pages. Here is how to configure basic authentication in NGINX.<\/p>\n","protected":false},"author":1,"featured_media":2386,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[237],"class_list":["post-2362","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","tag-basic-authentication"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Configure Basic Authentication in NGINX - Ubiq BI<\/title>\n<meta name=\"description\" content=\"NGINX basic authentication allows you to protect websites and web pages. Here is how to configure basic authentication 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-configure-basic-authentication-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 Configure Basic Authentication in NGINX - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"NGINX basic authentication allows you to protect websites and web pages. Here is how to configure basic authentication in NGINX.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-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:05:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-28T05:03:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/configure-basic-authentication-in-nginx.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\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=\"5 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-configure-basic-authentication-in-nginx\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How To Configure Basic Authentication in NGINX\",\"datePublished\":\"2020-11-25T06:05:24+00:00\",\"dateModified\":\"2025-08-28T05:03:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/\"},\"wordCount\":972,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1\",\"keywords\":[\"basic authentication\"],\"articleSection\":[\"Nginx\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/\",\"name\":\"How To Configure Basic Authentication in NGINX - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1\",\"datePublished\":\"2020-11-25T06:05:24+00:00\",\"dateModified\":\"2025-08-28T05:03:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"NGINX basic authentication allows you to protect websites and web pages. Here is how to configure basic authentication in NGINX.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1\",\"width\":1200,\"height\":720,\"caption\":\"how to configure basic authentication in nginx\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-configure-basic-authentication-in-nginx\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Configure Basic Authentication 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 Configure Basic Authentication in NGINX - Ubiq BI","description":"NGINX basic authentication allows you to protect websites and web pages. Here is how to configure basic authentication 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-configure-basic-authentication-in-nginx\/","og_locale":"en_US","og_type":"article","og_title":"How To Configure Basic Authentication in NGINX - Ubiq BI","og_description":"NGINX basic authentication allows you to protect websites and web pages. Here is how to configure basic authentication in NGINX.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-11-25T06:05:24+00:00","article_modified_time":"2025-08-28T05:03:46+00:00","og_image":[{"width":1200,"height":720,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/configure-basic-authentication-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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How To Configure Basic Authentication in NGINX","datePublished":"2020-11-25T06:05:24+00:00","dateModified":"2025-08-28T05:03:46+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/"},"wordCount":972,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1","keywords":["basic authentication"],"articleSection":["Nginx"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/","name":"How To Configure Basic Authentication in NGINX - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1","datePublished":"2020-11-25T06:05:24+00:00","dateModified":"2025-08-28T05:03:46+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"NGINX basic authentication allows you to protect websites and web pages. Here is how to configure basic authentication in NGINX.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/11\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1","width":1200,"height":720,"caption":"how to configure basic authentication in nginx"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-configure-basic-authentication-in-nginx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How To Configure Basic Authentication 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\/configure-basic-authentication-in-nginx.png?fit=1200%2C720&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-C6","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2362","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=2362"}],"version-history":[{"count":32,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2362\/revisions"}],"predecessor-version":[{"id":9316,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2362\/revisions\/9316"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/2386"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=2362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=2362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=2362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}