# Custom error\_page basic config problem

**URL:** <https://www.ruby-forum.com/t/custom-error-page-basic-config-problem/225549>\
**Category:** NGINX\
**Created:** [January 14, 2013, 11:03pm UTC](https://www.ruby-forum.com/t/custom-error-page-basic-config-problem/225549 "2013-01-14T23:03:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [January 14, 2013, 11:03pm UTC](https://www.ruby-forum.com/t/custom-error-page-basic-config-problem/225549/1 "2013-01-14T23:03:16Z")

</div>

Hi fellows,

I was having trouble creating a custom error\_page. Here’s the simple  
test  
config i did:

server\_name www.test1.com.ar;

error\_log logs/www.test1.com.ar.http.error.log debug;  
access\_log logs/www.test1.com.ar.http.access.log main;

root /usr/local/www/www.test1;

```
location / {

```

# Esto es para simular el geoip con un if.

if ( $remote\_addr = “10.24.18.2” ) {  
error\_page 401 /custom/404b.html;  
return 401;  
}  
}

With that, i only got the nginx default error page. After turning on  
debug  
i saw that when nginx goes to fetch the error\_page mentioned it searches  
in  
location / so it denies and send me the default error. Now i added a  
location like this

```
location = /custom/404b.html {

```

internal;  
}

Which made it work.

My question is is this is OK. If my solution is the correct one or  
perhaps  
theres a better one. Also, this test is easy cause its local, but i want  
to  
implemtn this in a proxy\_pass situation. Probably the intercept\_error…

Thanks for any hints you can give.

---

<div class="post-metadata">

**Author:** ![Agus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/90ced4/32.png) [@Agus](https://www.ruby-forum.com/u/Agus)\
**Post date:** [January 17, 2013, 8:00pm UTC](https://www.ruby-forum.com/t/custom-error-page-basic-config-problem/225549/2 "2013-01-17T20:00:30Z")

</div>

Weird. No one?

Cheers

2013/1/14 Agus [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Agus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/90ced4/32.png) [@Agus](https://www.ruby-forum.com/u/Agus)\
**Post date:** [January 21, 2013, 4:15am UTC](https://www.ruby-forum.com/t/custom-error-page-basic-config-problem/225549/3 "2013-01-21T04:15:00Z")

</div>

Hello!

On Mon, Jan 14, 2013 at 07:02:41PM -0300, Agus wrote:

> root /usr/local/www/www.test1;  
> With that, i only got the nginx default error page. After turning on debug  
> i saw that when nginx goes to fetch the error\_page mentioned it searches in  
> location / so it denies and send me the default error.

This is expected behaviour - you return 401 once again during  
error\_page handling, and hence get builtin error.

> Now i added a location like this
> 
> ```
> location = /custom/404b.html {
> 
> ```
> 
> internal;  
> }
> 
> Which made it work.

This is how it’s usually handled - via separate location without a  
check to deny access.

> My question is is this is OK. If my solution is the correct one or perhaps  
> theres a better one. Also, this test is easy cause its local, but i want to  
> implemtn this in a proxy\_pass situation. Probably the intercept\_error..
> 
> Thanks for any hints you can give.

Separate location for handling errors is fine.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
