Forum: NGINX Newbie config not catching virtual host.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F28f13d5607639b47a8ce7cf9b71a3cf?d=identicon&s=25 Nuno Magalhães (Guest)
on 2009-02-27 02:37
(Received via mailing list)
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
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 i get the default page at
wwwroot, no css or images;
if i enter http://my-cool-domain.com/subfolder i get the 404 error page;
if i enter 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
/etc/nginx/fastcgi_params http://pastebin.com/m4a40a295
/etc/nginx/sites-enabled/default 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
F28f13d5607639b47a8ce7cf9b71a3cf?d=identicon&s=25 Nuno Magalhães (Guest)
on 2009-02-27 14:44
(Received via mailing list)
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

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

Are there any suggestions?

Nuno Magalhães
LU#484677
F28f13d5607639b47a8ce7cf9b71a3cf?d=identicon&s=25 Nuno Magalhães (Guest)
on 2009-02-27 15:48
(Received via mailing list)
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 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 gives me a 404 (my own, since i've
configured 40x)

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 in the adress bar anymore.

Nuno Magalhães
LU#484677
F28f13d5607639b47a8ce7cf9b71a3cf?d=identicon&s=25 Nuno Magalhães (Guest)
on 2009-02-27 16:10
(Received via mailing list)
My new sites-enabled/default looks like this:
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/ 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
This topic is locked and can not be replied to.