Community Forums
Connect with us on LinkedIn
Community Notice
  
+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    Default 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.

Similar Threads & Tags
Similar threads

  1. EasyApache missed some vhosts
    By roopurt18 in forum New User Questions
    Replies: 1
    Last Post: 11-01-2009, 04:09 PM
  2. Run vhosts on two ports?
    By jnetsurfer in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 11-18-2007, 01:13 PM
  3. Cleanup of Vhosts
    By lloyd_tennison in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 08-08-2006, 05:02 PM
  4. Using /www/vhosts in cPanel???
    By jlfx in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 10-21-2004, 10:41 AM
  5. backup passwd.vhosts
    By silvernetuk in forum cPanel and WHM Discussions
    Replies: 10
    Last Post: 12-07-2002, 03:19 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube