Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 9th December 2010, 16:35
renders renders is offline
Junior Member
Join Date: Jan 2008
Location: Ontario Canada
Posts: 25
Thanks: 1
Thanked 6 Times in 4 Posts
Thumbs up A Working Nginx Catchall with ISPConfig 3.

Hi all.. I thought that I would share my working config after following the The NGINX Catchall for ISPconfig 3 howto.

I have 7 sites running, 2 drupal, 2 workpress and 3 custom php. This is running on a openvz vps with 16gb and 8 cpus. You should adjust your install accordingly. I sourced most of this info from the nginx forums..

It will pass thru all vhosts created within ispconfig with no impact. But, if you manually create vhost files for each site, nginx will serve the static files directly, greatly improving the speed of your sites. Apache is configured with 2048 max clients but with this config, barely uses 100. Yet nginx was running 4000 connections recently.

I have replaced the configs suggested in the howto with:

- main conf file
** needed the worker_rlimit_nofile to eliminate open file errors, default is 1024

user www-data;
worker_processes  3;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
worker_rlimit_nofile  4096;

events {
    worker_connections  2048;
    use epoll;

http {
    index index.php index.html index.htm;
    root  /var/www/;
    error_page   502 503 504  /50x.html;
    server_names_hash_max_size 512;
    server_names_hash_bucket_size 128;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    client_header_timeout   10m;
    client_body_timeout     10m;
    send_timeout            10m;
    connection_pool_size           512;
    client_header_buffer_size       1k;
    large_client_header_buffers     4 2k;
    request_pool_size               4k;
    client_body_temp_path /var/lib/nginx/body 1 2;  
    gzip  on;
    gzip_http_version 1.0;
    gzip_min_length  1100;
    gzip_types text/plain text/css image/x-icon application/x-javascript application/javascript text/javascript application/atom+xml application/xml;
    gzip_buffers 16 8k;    
    gzip_vary         on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    gzip_proxied  any;
    gzip_comp_level 2;

    output_buffers  1 32k;
    postpone_output 1460;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout       75 20;
    tcp_nodelay        off;
    ignore_invalid_headers  on;
    server_tokens off;

    access_log	  off;
    error_log     /var/log/nginx/error_log;

    #default nginx virtual host server
    #it's used if there is no other matching nginx virtual host found
    server {      
	listen	80 default;
	#you can access nginx internal stats using lynx or alike console based web browser     
	#at http://your.external.interface.ip/nginx_status address
	location /nginx_status {
	    stub_status on;
	    access_log   off;
	    deny all;
        #default proxy settings for each virtual host
        include /etc/nginx/proxy.conf;
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
- common proxy conf file.
** set the client_max_body_size to match apache max_file_size

location / {
   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       64m;
   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;
- if nginx cannot serve the file, pass it on to apache.

#proxy options can't be set inside if directive 
proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
 if (!-f $request_filename) {
If you want nginx to serve static files directly, you need to add the following for each vhost in the sites-available folder, linked to the sites-enabled folder
** PNG is removed due to a realtime file issue, I hope to resolve this properly.

server {
#   listen 80;
   server_name www.domain.com domain.com;
    #default proxy settings shared are among all virtual hosts
    access_log off;
    include /etc/nginx/proxy.conf;
      location ~* ^.+.(jpe?g|gif|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|html?|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3)$ {
           #forcing browser to cache locally static content for 1 day
           expires 1d;
           root /var/www/domain.com/web/;
           #access_log  /var/log/ispconfig/httpd/domain.com/access.log;
           access_log  off;
           #graceful fallback in case if static content doesn't exist
	   include /etc/nginx/proxy_fallback.conf;
Good luck, I hope you find this helpful.


Last edited by renders; 9th December 2010 at 17:06.
Reply With Quote
The Following 3 Users Say Thank You to renders For This Useful Post:
falko (10th December 2010), talkingnews (17th April 2011), till (9th December 2010)
Sponsored Links


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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPConfig 3 Send/Receive mail not working. Acidut General 6 4th April 2010 12:24
Hosting multiple websites and webmail dmwcool Installation/Configuration 8 30th March 2010 04:15
Ftp problems timeout reny2000 General 6 23rd December 2009 12:09
The autoresponse is not working with ISPConfig voltron81 Installation/Configuration 4 13th October 2009 14:03
Working through the ISPConfig source code catdude General 1 25th August 2007 09:38

All times are GMT +2. The time now is 05:57.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.