How to restrict access to a URL in Ngnix

ngnix-logoSometimes it needs to restrict some URLs of your application. Suppose, if you have a WordPress application then it doesn’t need to give access to the URL to all. If you are restricting the URL then you are also preventing brute force attack to to URL. If the URL is available to all then some one can hack your blog/ website by doing a brute force attack.

In this tutorial I will explain you how to restrict URL’s when you are using nginx as your webserver.

Edit your nginx configuration file.

Append the below code to the configuration file.

Save the file after modification and now we need to test the configuration and restart the nginx to run with the new configuration.

Test the configuration:

Restart the ngnix

Now you can access the URL from the IP
Please change the configurations as per your requirement.

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply