# HTTP status code bug?

**URL:** <https://www.ruby-forum.com/t/http-status-code-bug/182926>\
**Category:** NGINX\
**Created:** [February 4, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/http-status-code-bug/182926 "2010-02-04T21:54:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 4, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/http-status-code-bug/182926/1 "2010-02-04T21:54:02Z")

</div>

Hello,

The browser hits a non-existing file. An “error\_page” points  
to a fastcgi-application. The fastcgi thinks this is not an error  
and explicit sets: “Status: 200” or “Status: 302”, …

One would expect that the fastcgi can overwrite the status-code.

E.g.: [http://www.domain.name/media/id12345](http://www.domain.name/media/id12345)  
nginx returns 404, regardless of the fastcgi.

http {  
server {  
listen 80;  
server\_name www.domain.name;  
error\_page 404 /index.cgi;  
location / {  
index index.cgi;  
fastcgi\_pass unix:/var/run/fastcgi/dispatch.sock;  
…;  
}  
location ^~ /media/ {  
alias /var/www/media/;  
}  
}  
}

Thanks  
Marcus

Posted at Nginx Forum:

> **[HTTP status code bug?](https://forum.nginx.org/read.php?2,50668,50668#msg-50668)**
>
> Hello, The browser hits a non-existing file. An "error\_page" points to a fastcgi-application. The fastcgi thinks this is not an error and explicit sets: "Status: 200" or "Status: 302", ... One would expect that the...

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 4, 2010, 10:49pm UTC](https://www.ruby-forum.com/t/http-status-code-bug/182926/2 "2010-02-04T22:49:03Z")

</div>

Hello!

On Thu, Feb 04, 2010 at 03:53:21PM -0500, double wrote:

> The browser hits a non-existing file. An “error\_page” points  
> to a fastcgi-application. The fastcgi thinks this is not an error  
> and explicit sets: “Status: 200” or “Status: 302”, …
> 
> One would expect that the fastcgi can overwrite the status-code.

Normally error pages are mapped to static files, and their status  
is obviously 200. It would be a bit strange to return status 200  
just because error page was found, right?

If you want to override original error code with one returned by  
error page itself, you should use ‘=’ in error\_page directive.  
See here for more details:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

> E.g.: [http://www.domain.name/media/id12345](http://www.domain.name/media/id12345)  
> nginx returns 404, regardless of the fastcgi.
> 
> http {  
> server {  
> listen 80;  
> server\_name www.domain.name;  
> error\_page 404 /index.cgi;

- 

```
    error_page 404 /index.cgi;

```

- 

```
    error_page 404 = /index.cgi;

```

> ```
> location / {
> index index.cgi;                   
> fastcgi_pass unix:/var/run/fastcgi/dispatch.sock;
> ....;        
> }                                                          
> location ^~ /media/ {                              
> alias /var/www/media/;            
> }                                                          
> }
> 
> ```
> 
> }

Maxim D.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 4, 2010, 11:10pm UTC](https://www.ruby-forum.com/t/http-status-code-bug/182926/3 "2010-02-04T23:10:07Z")

</div>

Hi Maxim,

Thank you very much for your help!  
RTFM  
🙂

Marcus

Posted at Nginx Forum:

> **[Re: HTTP status code bug?](https://forum.nginx.org/read.php?2,50668,50691#msg-50691)**
>
> Hello, The browser hits a non-existing file. An "error\_page" points to a fastcgi-application. The fastcgi thinks this is not an error and explicit sets: "Status: 200" or "Status: 302", ... One would expect that the...
