The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Vhosts

Discussion in 'General Discussion' started by dtredwell, Jun 3, 2007.

  1. dtredwell

    dtredwell Registered

    Joined:
    Jun 3, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    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
     
    #1 dtredwell, Jun 3, 2007
    Last edited: Jun 3, 2007
Loading...

Share This Page