#1 (permalink)  
Old 06-03-2007, 09:05 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
dtredwell is on a distinguished road
Vhosts

Im looking to run nginx infront of apache to serve static content. I did some research on this with lighttpd a while back, if i remember right, the only problem is virtual hosts.

I can see two ways of getting this to work with cpanel;
either modify the vhost creation function, to mirror them into nginx's config
or to have a cron or something that enumerates all of the ( or the latest ) vhosts added by cpanel, and updates the nginx config accordingly.

now, in nginx the vhost exsample is like so;
Code:
http {
    server {
        listen          80;
        server_name     www.domain1.com;
        access_log      logs/domain1.access.log main;

        location / {
            index index.html;
            root  /var/www/domain1.com/htdocs;
        }
    }

    server {
        listen          80;
        server_name     www.domain2.com;
        access_log      logs/domain2.access.log main;

        location / {
            index index.html;
            root  /var/www/domain2.com/htdocs;
        }
    }
}
and an exsample of runing a proxy:

Code:
server {
        listen       80;
        server_name  some-server.com www.server-name.com;

        access_log  logs/host.access.log  main;

        # Main location
        location / {
            proxy_pass         http://127.0.0.1:8080/;
            proxy_redirect     off;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
        }

        # Static files location
        location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ {
            root   /spool/www/members_ng;
        }

    }
It definately looks do-able, what do you guys think?
And what would be the best way to go about setting this one up?
Edit: probably posted in the wrong forum, haha

Last edited by dtredwell; 06-03-2007 at 09:10 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:50 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© cPanel Inc