{"id":2745,"date":"2020-12-16T06:06:34","date_gmt":"2020-12-16T06:06:34","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=2745"},"modified":"2025-09-24T07:36:42","modified_gmt":"2025-09-24T07:36:42","slug":"nginx-restrict-access-to-url","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/","title":{"rendered":"How to Restrict URL Access in NGINX"},"content":{"rendered":"\n<p>Sometimes you need to limit access to one or more URLs on your website. This is especially true if you find bots requesting URLs that do not exist on your website, as it can bring down your server. There are several ways to block URL access on NGINX server. In this article, we will look at how to restrict access to URL 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\/nginx-restrict-access-to-url\/#Why_Block_URL_Access_in_NGINX\" >Why Block URL Access 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\/nginx-restrict-access-to-url\/#How_to_Restrict_Access_to_URL_in_NGINX\" >How to Restrict Access to URL 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\/nginx-restrict-access-to-url\/#1_Open_NGINX_configuration_file\" >1. 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-4\" href=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#2_Restrict_Access_to_URL\" >2. Restrict Access to URL<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#Restrict_Access_from_Single_IP\" >Restrict Access from Single IP<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#Restrict_Access_from_Multiple_IP\" >Restrict Access from Multiple IP<\/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\/nginx-restrict-access-to-url\/#Block_Access_from_IP_Range\" >Block Access from IP Range<\/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\/nginx-restrict-access-to-url\/#Block_Access_from_All_IPs\" >Block Access from All IPs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#Block_Access_to_Multiple_URLs\" >Block Access to Multiple URLs<\/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\/nginx-restrict-access-to-url\/#Allow_Access_from_Only_One_IP\" >Allow Access from Only One IP<\/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\/nginx-restrict-access-to-url\/#Deny_vs_Return_Statement\" >Deny vs Return Statement<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#3_Restart_NGINX_Server\" >3. Restart NGINX Server<\/a><\/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\/nginx-restrict-access-to-url\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Block_URL_Access_in_NGINX\"><\/span>Why Block URL Access in NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Generally, NGINX is used as a proxy server along with an application server such as Apache. Every request sent to your website is received by NGINX before it is passed to the application server. If a bot keeps requesting non-existent URLs on your website, your application server will be busy responding with &#8216;404:Page not found&#8217;. If it receives too many such requests, then it may become overloaded and crash quickly. Therefore, it is important to block such URLs in NGINX itself so that they do not pass to application server.<\/p>\n\n\n\n<p>Another reason for restricting URL access is when it contains sensitive or private information. In such cases, you will need to restrict, if not block access, to the URL. For example, you may not want everyone to have access to the admin pages of your website. In this case also, you can use NGINX to easily control URL access, without modifying any code on your site.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Restrict_Access_to_URL_in_NGINX\"><\/span>How to Restrict Access to URL in NGINX<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For our purpose, we will use <a href=\"https:\/\/nginx.org\/en\/docs\/http\/ngx_http_access_module.html#deny\" target=\"_blank\" rel=\"noreferrer noopener\">Deny<\/a> directive that is already available in every NGINX server configuration by default. Here are the steps to restrict access to URL in NGINX.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Open_NGINX_configuration_file\"><\/span>1. 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 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 <em>\/etc\/nginx\/sites-enabled\/example.conf<\/em> 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\/example.conf<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Restrict_Access_to_URL\"><\/span>2. Restrict Access to URL<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us say you want to limit access to <em>\/product<\/em>.html URL by IP 45.34.21.10. In that case, add the following <em>Deny<\/em> directive in the location block of this URL.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Deny 45.34.21.10<\/pre>\n\n\n\n<p>Now let us learn several common use cases to restrict URL access in NGINX.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Restrict_Access_from_Single_IP\"><\/span>Restrict Access from Single IP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Here is the simplest case where you need to block access to a single URL from a single IP address. Add the following in the location block for <em>\/product.html<\/em>, in your NGINX server configuration.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">location \/product.html {\n   ...\n   deny 45.34.21.10;\n   ...\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Restrict_Access_from_Multiple_IP\"><\/span>Restrict Access from Multiple IP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to limit URL access for multiple IPs, add separate Deny statements, one for each IP as shown. Here is an example to block requests from IPs 45.34.21.10 and 54.23.10.13.<\/p>\n\n\n\n<pre id=\"block-5426c195-9337-4445-b4ae-a195f1ab66a1\" class=\"wp-block-preformatted\">location \/product.html {<br>   ...<br>   Deny 45.34.21.10;<br>   Deny 54.23.10.13;<br>   ...<br>}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Block_Access_from_IP_Range\"><\/span>Block Access from IP Range<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to limit access to URL for an IP range such as 45.23.10.0-45.23.10.255 then specify IP range using <a href=\"https:\/\/www.ipaddressguide.com\/cidr\" target=\"_blank\" rel=\"noreferrer noopener\">CIDR notation<\/a>.<\/p>\n\n\n\n<pre id=\"block-c04457f9-d1bf-4951-bb1f-f63fe49dc40e\" class=\"wp-block-preformatted\">location \/product.html {\n   ...\n   Deny 45.34.21.0\/24;\n   ...\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Block_Access_from_All_IPs\"><\/span>Block Access from All IPs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to block access from all IP addresses, then simply add &#8216;Deny All&#8217; statement in your location block as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">location \/product.html {<br>   ...<br>   Deny All;<br>   ...<br>}<\/pre>\n\n\n\n<p>When you use Deny directive, NGINX will return 403: Access Forbidden response. This may alert the attacker that the page exists but they do not have access, prompting them to try other methods. It is safer to simply return 404: Page not found message instead.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">location \/product.html {<br>   ...<br>   return 404;<br>   ...<br>}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Block_Access_to_Multiple_URLs\"><\/span>Block Access to Multiple URLs<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can also use the same Deny statement to block access to multiple URLs, by combining them using pipe (I) operator.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">location ~ \/(login|admin)\\.php$<br> {<br>     Deny 45.34.21.10;<br> }<\/pre>\n\n\n\n<p>Quite often, websites receive bogus requests for .php or .jsp pages even though their website is not built using either of these technologies. This is done to determine your tech stack, based on server responses, and exploit its vulnerabilities.<\/p>\n\n\n\n<p>Here is an example to easily block all such requests. It will block requests to .php, .jsp, .asp and .perl pages. You can customize it as per your requirement.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">location ~ (\\.php$|\\.jsp$|\\.asp$|\\.perl$) <br>{<br>     return 404;<br>}<br><br>OR<br><br>location ~ (\\.php$|\\.jsp$|\\.asp$|\\.perl$) <br>{<br>     Deny All;<br>}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Allow_Access_from_Only_One_IP\"><\/span>Allow Access from Only One IP<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to restrict access to URL by all IPs except one known IP 45.34.21.10, then add the following Deny and Allow statements as shown.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">location \/login.php {<br>   ...<br>   Allow 45.34.21.10;<br>   Deny All;<br>   ...<br>}<\/pre>\n\n\n\n<p>The allow statement will allow access to specified IP and deny statement will limit access to all other IPs. This is very useful to control access to your website&#8217;s admin pages and other pages that contain sensitive information.<\/p>\n\n\n\n<p>If <a href=\"https:\/\/ubiq.co\/tech-blog\/enable-cors-nginx\/\">Cross Origin Resource Sharing (CORS) is enabled on NGINX server<\/a>, check if it poses conflicting rules with your Allow\/Deny directives.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Deny_vs_Return_Statement\"><\/span>Deny vs Return Statement<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>NGINX allows you to block URL access using Deny as well as Return statements. You can use Deny statement to precisely block access from specific IP addresses and ranges. Alternatively, you can also use return statement to return 403 or 404 response code to all IPs. <\/p>\n\n\n\n<p>The key difference between Deny and return statement is that Deny statement returns 403 response only to specific IPs but return statement sends the same response to all IP addresses. On the other hand, Deny statement will always return 403 response code whereas return statement can be customized to return different response codes. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Restart_NGINX_Server\"><\/span>3. Restart NGINX Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Finally, 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<br>$ systemctl restart nginx #redhat\/centos<\/pre>\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 restrict access to URL in NGINX. We have learnt several common use cases to block access from one IP, multiple IPs, IP ranges. We have also learnt how to block access to multiple URLs using single location block. Although we have learnt how to block URL access, the same directives can be used to deny access to directories as well as files. The key is to first identify the malicious IP addresses using NGINX server log and then block them in server config file.<\/p>\n\n\n\n<p>Also read : <br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-configure-nginx-log-rotation\/\">How to Configure NGINX Log Rotation<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-fix-nginx-worker-connections-are-not-enough\/\">How to Fix NGINX Worker Connections Not Enough<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-disable-etag-in-nginx\/\">How to Disable ETag in NGINX<\/a><\/p>\n\n\n\n<p><a href=\"http:\/\/ubiq.co\/\">Ubiq<\/a>&nbsp;makes it easy to visualize data in minutes, and monitor in real-time dashboards.&nbsp;<a href=\"http:\/\/ubiq.co\/accounts\/register\">Try it<\/a> today!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you may need to limit access to URL. Here is how to restrict access to URL in NGINX.<\/p>\n","protected":false},"author":1,"featured_media":2750,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[249],"class_list":["post-2745","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","tag-restrict-access"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Restrict URL Access in NGINX - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes you may need to limit access to URL in NGINX server. Learn how to restrict access to URL 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\/nginx-restrict-access-to-url\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Restrict URL Access in NGINX - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes you may need to limit access to URL in NGINX server. Learn how to restrict access to URL in NGINX.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/\" \/>\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-12-16T06:06:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-24T07:36:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/12\/restrict-access-url-in-nginx.png\" \/>\n\t<meta property=\"og:image:width\" content=\"805\" \/>\n\t<meta property=\"og:image:height\" content=\"488\" \/>\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\\\/nginx-restrict-access-to-url\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Restrict URL Access in NGINX\",\"datePublished\":\"2020-12-16T06:06:34+00:00\",\"dateModified\":\"2025-09-24T07:36:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/\"},\"wordCount\":985,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1\",\"keywords\":[\"restrict access\"],\"articleSection\":[\"Nginx\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/\",\"name\":\"How to Restrict URL Access in NGINX - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1\",\"datePublished\":\"2020-12-16T06:06:34+00:00\",\"dateModified\":\"2025-09-24T07:36:42+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes you may need to limit access to URL in NGINX server. Learn how to restrict access to URL in NGINX.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1\",\"width\":805,\"height\":488,\"caption\":\"restrict access to url in nginx\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/nginx-restrict-access-to-url\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Restrict URL Access 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 Restrict URL Access in NGINX - Ubiq BI","description":"Sometimes you may need to limit access to URL in NGINX server. Learn how to restrict access to URL 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\/nginx-restrict-access-to-url\/","og_locale":"en_US","og_type":"article","og_title":"How to Restrict URL Access in NGINX - Ubiq BI","og_description":"Sometimes you may need to limit access to URL in NGINX server. Learn how to restrict access to URL in NGINX.","og_url":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2020-12-16T06:06:34+00:00","article_modified_time":"2025-09-24T07:36:42+00:00","og_image":[{"width":805,"height":488,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/12\/restrict-access-url-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\/nginx-restrict-access-to-url\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Restrict URL Access in NGINX","datePublished":"2020-12-16T06:06:34+00:00","dateModified":"2025-09-24T07:36:42+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/"},"wordCount":985,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/12\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1","keywords":["restrict access"],"articleSection":["Nginx"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/","url":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/","name":"How to Restrict URL Access in NGINX - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/12\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1","datePublished":"2020-12-16T06:06:34+00:00","dateModified":"2025-09-24T07:36:42+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes you may need to limit access to URL in NGINX server. Learn how to restrict access to URL in NGINX.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/12\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2020\/12\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1","width":805,"height":488,"caption":"restrict access to url in nginx"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/nginx-restrict-access-to-url\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Restrict URL Access 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\/12\/restrict-access-url-in-nginx.png?fit=805%2C488&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-Ih","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2745","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=2745"}],"version-history":[{"count":16,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2745\/revisions"}],"predecessor-version":[{"id":9642,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/2745\/revisions\/9642"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/2750"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=2745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=2745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=2745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}