# Blocking all the URL except 1

**URL:** <https://www.ruby-forum.com/t/blocking-all-the-url-except-1/244846>\
**Category:** NGINX\
**Created:** [June 23, 2016, 6:48pm UTC](https://www.ruby-forum.com/t/blocking-all-the-url-except-1/244846 "2016-06-23T18:48:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [June 23, 2016, 6:48pm UTC](https://www.ruby-forum.com/t/blocking-all-the-url-except-1/244846/1 "2016-06-23T18:48:26Z")

</div>

Hi

We have a Nginx Box which acts as a reverse proxy to backend  
applications.

We only want to allow traffic on [http://example.com](http://example.com) which internally  
redirects to specific application. Other then that, every other URI  
should  
be blocked.

For example :-

[example.com](http://example.com) Allowed  
[example.com/test](http://example.com/test) Blocked  
[example.com/login](http://example.com/login) Blocked

How can I achieve this ?

Any help will be appreciated.

---

<div class="post-metadata">

**Author:** ![Zeal\_Vora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e79b87/32.png) [@Zeal\_Vora](https://www.ruby-forum.com/u/Zeal_Vora)\
**Post date:** [June 23, 2016, 6:50pm UTC](https://www.ruby-forum.com/t/blocking-all-the-url-except-1/244846/2 "2016-06-23T18:50:11Z")

</div>

Hi,

On Fri, Jun 24, 2016, at 01:47, Zeal Vora wrote:

> For example :-
> 
> [example.com](http://example.com) Allowed  
> [example.com/test](http://example.com/test) Blocked  
> [example.com/login](http://example.com/login) Blocked
> 
> How can I achieve this ?

does this work?

location = / {  
return 302 https://…  
}

location / {  
return 404;  
}

---

<div class="post-metadata">

**Author:** ![Zeal\_Vora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e79b87/32.png) [@Zeal\_Vora](https://www.ruby-forum.com/u/Zeal_Vora)\
**Post date:** [June 24, 2016, 9:32am UTC](https://www.ruby-forum.com/t/blocking-all-the-url-except-1/244846/3 "2016-06-24T09:32:16Z")

</div>

Thanks. The above lined helped. However one more doubt. I want NGINX to  
return 200 whenever some one goes to /nature , so I wrote above  
configuration, however when some one goes to /nature , NGINX gives it  
404  
instead of 200. Here is my configuration :-

server {  
location = /nature {  
return 200;  
}  
}

server {  
listen 80;  
server\_name [example.com](http://example.com);

```
location = / {
     proxy_pass http://app:server;
}

location / {
     return 404;
 }

```

}

---

<div class="post-metadata">

**Author:** ![Zeal\_Vora](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/e79b87/32.png) [@Zeal\_Vora](https://www.ruby-forum.com/u/Zeal_Vora)\
**Post date:** [June 24, 2016, 3:34pm UTC](https://www.ruby-forum.com/t/blocking-all-the-url-except-1/244846/4 "2016-06-24T15:34:26Z")

</div>

Why do you have that in a separate server block?
