Ruby Forum NGINX > Problem with a virtualhost

Posted by David (Guest)
on 06.09.2008 16:45
(Received via mailing list)
Hello,

I am able to access domain.org.uk but www.domain.org.uk 404s and 
defaults to the
nginx welcome page. It's behaving as if it cannot find a 
www.domain.org.uk match
so resorts to the default nginx page.

I can't see anything wrong with my conf. Any ideas ?

Thank you



server {
        listen          192.168.30.12;
        server_name     domain.org.uk www.domain.org.uk;
        access_log      /var/log/nginx/domain.org.uk.access.log main;

        location / {
                index   index.php index.html index.htm;
                root    /home/user/public_html;
        }

        location ^~ / {
                auth_basic            "Authorization Required";
                auth_basic_user_file 
/home/user/not_web_accessible/.htpasswd;
        }

        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_intercept_errors  on;
                fastcgi_param  SCRIPT_FILENAME
/home/user/public_html$fastcgi_script_name;
                include /usr/local/nginx/fastcgi_params;
        }

        # serve static files directly
        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {
            access_log        off;
            expires           2d;
        }

        # prevent access to .htaccess if still exist
        location ~ /\.ht {
                deny  all;
        }

}
Posted by David (Guest)
on 06.09.2008 16:45
(Received via mailing list)
BTW I can't really use the wildcard *.domain.org.uk as I will probably 
add
subdomains at some point.
Posted by David (Guest)
on 06.09.2008 17:06
(Received via mailing list)
I must've made a typo in my conf somewhere because when I copied a 
working conf
over and re-editted it it worked fine.
Posted by Chris Savery (Guest)
on 06.09.2008 17:20
(Received via mailing list)
I see you got the answer now. Was just going to say make sure your dns
is correct for the www.
Just in case you don't know you can (or should) test your config with:
nginx -t
If the config has an error and you send a HUP then it will keep the old
one so your changes may not have been picked up. That can cause
confusion if you don't use -t everytime.
Chris :)
Posted by mike (Guest)
on 06.09.2008 23:29
(Received via mailing list)
On Sat, Sep 6, 2008 at 7:32 AM, David <mishy.cth@gmail.com> wrote:

>        location ~ \.php$ {
>                fastcgi_pass 127.0.0.1:9000;
>        }

just for cleanup/simplicity...

you can put these into fastcgi_params:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_intercept_errors  on;

and this can be included only once globally (or, you can just put the
contents directly into http {} just once and skip having a separate
file)

include /usr/local/nginx/fastcgi_params;

:)