Problem with a virtualhost


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

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

Thank you

server {
access_log /var/log/nginx/ main;

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

    location ^~ / {
            auth_basic            "Authorization Required";


    location ~ \.php$ {
            fastcgi_index index.php;
            fastcgi_intercept_errors  on;
            fastcgi_param  SCRIPT_FILENAME

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;


BTW I can’t really use the wildcard * as I will probably
subdomains at some point.

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.

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 :slight_smile:

On Sat, Sep 6, 2008 at 7:32 AM, David [email protected] wrote:

   location ~ \.php$ {

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

include /usr/local/nginx/fastcgi_params;


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs