# Very wierd config error

**URL:** <https://www.ruby-forum.com/t/very-wierd-config-error/218845>\
**Category:** NGINX\
**Created:** [April 13, 2012, 1:03pm UTC](https://www.ruby-forum.com/t/very-wierd-config-error/218845 "2012-04-13T13:03:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [April 13, 2012, 1:03pm UTC](https://www.ruby-forum.com/t/very-wierd-config-error/218845/1 "2012-04-13T13:03:37Z")

</div>

Hello!  
I’m sorry to bother the forum with these kind of questions, but I simply  
can’t figure out what I’m doing wrong here:

When I access [sub.domain.net/](http://sub.domain.net/) I still get the 502 error instead of being  
served from the /somefolder/stuff folder?..

server {  
listen 80;  
server\_name [sub.domain.net](http://sub.domain.net);

location = / {  
root /somefolder/stuff;  
index index.html index.htm;

}

location / {

return 502;

}

}

Posted at Nginx Forum:

> **[Very wierd config error..](https://forum.nginx.org/read.php?2,225300,225300#msg-225300)**
>
> Hello! I'm sorry to bother the forum with these kind of questions, but I simply can't figure out what I'm doing wrong here: When I access sub.domain.net/ I still get the 502 error instead of being served from the /somefolder/stuff folder?.... server...

---

<div class="post-metadata">

**Author:** ![alexscott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@alexscott](https://www.ruby-forum.com/u/alexscott)\
**Post date:** [April 13, 2012, 1:11pm UTC](https://www.ruby-forum.com/t/very-wierd-config-error/218845/2 "2012-04-13T13:11:05Z")

</div>

Hello!

On Fri, Apr 13, 2012 at 07:02:45AM -0400, alexscott wrote:

> }
> 
> }

Detailed explanation is given here:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration)**
>
> nginx first decides which server should process the request. Let’s start with a simple configuration where all three virtual servers listen on port \*:80:

In short: request to “/” is internally redirected to  
“/index.html”, and then handled in “location /”. Try this  
instead:

```
root /somefolder/stuff;

location = / {
    index index.html index.htm;
}

location = /index.html {
    internal;
}

location = /index.htm {
    internal;
}

location / {
    return 502;
}

```

Maxim D.

---

<div class="post-metadata">

**Author:** ![alexscott](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@alexscott](https://www.ruby-forum.com/u/alexscott)\
**Post date:** [April 13, 2012, 2:23pm UTC](https://www.ruby-forum.com/t/very-wierd-config-error/218845/3 "2012-04-13T14:23:52Z")

</div>

## Maxim D. Wrote:

> > When I access [sub.domain.net/](http://sub.domain.net/) I still get the
> 
> Detailed explanation is given here:
> 
> ```
> }
> 
> ```
> 
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)  
> You can also do this without adding new locations by using try\_files  
> instead of index.

root /somefolder/stuff;

location = / {  
try\_files /index.html /index.htm =404;  
}

location / {  
return 502;  
}

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,225300,225305#msg-225305](http://forum.nginx.org/read.php?2,225300,225305#msg-225305)
