# Proxy\_pass check if 404, and return 404

**URL:** <https://www.ruby-forum.com/t/proxy-pass-check-if-404-and-return-404/238381>\
**Category:** NGINX\
**Created:** [January 8, 2014, 12:04am UTC](https://www.ruby-forum.com/t/proxy-pass-check-if-404-and-return-404/238381 "2014-01-08T00:04:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [January 8, 2014, 12:04am UTC](https://www.ruby-forum.com/t/proxy-pass-check-if-404-and-return-404/238381/1 "2014-01-08T00:04:03Z")

</div>

I am using proxy\_pass to a dynamic subdomain:

```
proxy_pass https://$remote_user.mydomain.io

```

Is it possible to have the proxy\_pass check if the response of  
https://$remote\_user.mydomain.io is 404, if so, simply do:

```
return 404;

```

I.E. don’t proxy, immediately return.

Posted at Nginx Forum:

> **[proxy\_pass check if 404, and return 404](https://forum.nginx.org/read.php?2,246112,246112#msg-246112)**
>
> I am using proxy\_pass to a dynamic subdomain: proxy\_pass https://$remote\_user.mydomain.io Is it possible to have the proxy\_pass check if the response of https://$remote\_user.mydomain.io is 404, if so, simply do: return 404; I.E. don

---

<div class="post-metadata">

**Author:** ![justink101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@justink101](https://www.ruby-forum.com/u/justink101)\
**Post date:** [January 8, 2014, 12:57am UTC](https://www.ruby-forum.com/t/proxy-pass-check-if-404-and-return-404/238381/2 "2014-01-08T00:57:50Z")

</div>

The _only_ context I can see this being even slightly useful is where  
you are concerned about the unacceptably large size of the upstream  
server’s 404 page.

If this isn’t your problem, I don’t understand what you’re trying to  
solve.

---

<div class="post-metadata">

**Author:** ![justink101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@justink101](https://www.ruby-forum.com/u/justink101)\
**Post date:** [January 8, 2014, 1:10am UTC](https://www.ruby-forum.com/t/proxy-pass-check-if-404-and-return-404/238381/3 "2014-01-08T01:10:41Z")

</div>

On 7 January 2014 23:57, Jonathan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> The _only_ context I can see this being even slightly useful is where  
> you are concerned about the unacceptably large size of the upstream  
> server’s 404 page.
> 
> If this isn’t your problem, I don’t understand what you’re trying to solve.

Either way, I should have said, look at the error\_page directive.

HTH,  
J

---

<div class="post-metadata">

**Author:** ![justink101](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a587f6/32.png) [@justink101](https://www.ruby-forum.com/u/justink101)\
**Post date:** [January 8, 2014, 5:21am UTC](https://www.ruby-forum.com/t/proxy-pass-check-if-404-and-return-404/238381/4 "2014-01-08T05:21:59Z")

</div>

On Wednesday 08 January 2014 00:10:16 Jonathan M. wrote:

> On 7 January 2014 23:57, Jonathan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > The _only_ context I can see this being even slightly useful is where  
> > you are concerned about the unacceptably large size of the upstream  
> > server’s 404 page.
> > 
> > If this isn’t your problem, I don’t understand what you’re trying to  
> > solve.
> 
> Either way, I should have said, look at the error\_page directive.

…and “proxy\_intercept\_errors”.

[http://nginx.org/r/proxy\_intercept\_errors](http://nginx.org/r/proxy_intercept_errors)

wbr, Valentin V. Bartenev
