# Newbie config not catching virtual host

**URL:** <https://www.ruby-forum.com/t/newbie-config-not-catching-virtual-host/161513>\
**Category:** NGINX\
**Created:** [February 27, 2009, 2:37am UTC](https://www.ruby-forum.com/t/newbie-config-not-catching-virtual-host/161513 "2009-02-27T02:37:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nuno\_MagalhSSSSes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c89c15/32.png) [@Nuno\_MagalhSSSSes](https://www.ruby-forum.com/u/Nuno_MagalhSSSSes)\
**Post date:** [February 27, 2009, 2:37am UTC](https://www.ruby-forum.com/t/newbie-config-not-catching-virtual-host/161513/1 "2009-02-27T02:37:39Z")

</div>

Greetings,

I’ve just set up a domain name and i can’t get nginx to parse to the  
correct subfolder. I think this is related to fastcgi, caused by an  
error between my chair and keyboard.

I have /var/www/nginx-default/ with a default page; and i have a  
subfolder with a site, so /var/www/nginx-default/subfolder/

- What i want:  
If a user enters: [http://my-cool-domain.com](http://my-cool-domain.com)  
s/he should get: /var/www/nginx-default/subfolder/  
which would become: /var/www/nginx-default/subfolder/index.php  
(preferably without showing the filename in the adress bar)

- What i have:  
If i enter [http://my-cool-domain.com](http://my-cool-domain.com) i get the default page at  
wwwroot, no css or images;  
if i enter [http://my-cool-domain.com/subfolder](http://my-cool-domain.com/subfolder) i get the 404 error page;  
if i enter [http://my-cool-domain.com/subfolder/index.php](http://my-cool-domain.com/subfolder/index.php) i get the  
page i want, php-parsed, no css or images.  
This is the same if i use the IP adress instead (only much faster),  
although browser-caching had me confused for a while…

This is my config:

/etc/nginx/nginx.conf [http://pastebin.com/m618b1c46](http://pastebin.com/m618b1c46)  
/etc/nginx/fastcgi\_params [http://pastebin.com/m4a40a295](http://pastebin.com/m4a40a295)  
/etc/nginx/sites-enabled/default [http://pastebin.com/m111dd757](http://pastebin.com/m111dd757)

I’m sure there are things i could replace with variables, set up a  
default catch all, etc, but i’d take one step at a time…  
This is probaby a missing coma or something, any help would be  
appreciated.

Nuno MagalhÃ£es  
LU#484677

---

<div class="post-metadata">

**Author:** ![Nuno\_MagalhSSSSes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c89c15/32.png) [@Nuno\_MagalhSSSSes](https://www.ruby-forum.com/u/Nuno_MagalhSSSSes)\
**Post date:** [February 27, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/newbie-config-not-catching-virtual-host/161513/2 "2009-02-27T14:44:56Z")

</div>

I’ve changed sites-enabled so that it has default, which is a symlink  
to sites-available/default. I have the 40x.html page both in the / and  
in /mysite directories, with the right permissions.  
I’ve changed sites-available/default to this  
[http://pastebin.com/m2e7c6869](http://pastebin.com/m2e7c6869)

Now i get 301 or redirect loop complaints, depending on the browser.  
Also, if i use [http://1.2.3.4](http://1.2.3.4) isntead of [domain.com](http://domain.com) i get redirected  
to [domain.com](http://domain.com) anyway.

Are there any suggestions?

Nuno MagalhÃ£es  
LU#484677

---

<div class="post-metadata">

**Author:** ![Nuno\_MagalhSSSSes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c89c15/32.png) [@Nuno\_MagalhSSSSes](https://www.ruby-forum.com/u/Nuno_MagalhSSSSes)\
**Post date:** [February 27, 2009, 3:48pm UTC](https://www.ruby-forum.com/t/newbie-config-not-catching-virtual-host/161513/3 "2009-02-27T15:48:34Z")

</div>

Ok i wasn’t even getting my error page, which tend to happen if you  
only specify the 50x. I’ve fiddled some more and came back to where i  
was before, i.e.,

[http://domain.com](http://domain.com) gets me the root page, php is parsing (i have  
includes), css isn’t used, images don’t show up, so i’m missing a root  
somewhere…

[http://domain.com/domaindir](http://domain.com/domaindir) gives me a 404 (my own, since i’ve  
configured 40x)

[http://domain.com/domaindir/index.php](http://domain.com/domaindir/index.php) gives me the index, php parsed,  
no css or images.

The same happens if i use the ip adress instead and it’s not changing  
to [domain.com](http://domain.com) in the adress bar anymore.

Nuno MagalhÃ£es  
LU#484677

---

<div class="post-metadata">

**Author:** ![Nuno\_MagalhSSSSes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c89c15/32.png) [@Nuno\_MagalhSSSSes](https://www.ruby-forum.com/u/Nuno_MagalhSSSSes)\
**Post date:** [February 27, 2009, 4:10pm UTC](https://www.ruby-forum.com/t/newbie-config-not-catching-virtual-host/161513/4 "2009-02-27T16:10:55Z")

</div>

My new sites-enabled/default looks like this:  
[http://pastebin.com/d36e0020f](http://pastebin.com/d36e0020f)

The only place i’m referring the domain dir is here:  
location / {  
root /var/www/nginx-default/domaindir;  
#root /domaindir;  
index index.php index.html;  
}  
The rest of the file doesn’t use the domaindir. However, trying to go  
to [http://domain.com/](http://domain.com/) won’t take me to the show me the domain’s index  
but rather the nginx root index. The error log reports this:  
2009/02/27 14:57:14 [error] 11880#0: \*6 open()  
“/var/www/nginx-default/domaindir/imagefile.png” failed (2: No such  
file or directory)

But that image file is in the nginx root, not in the domaindir.

Nuno MagalhÃ£es  
LU#484677
