Does Aegir Hosting System work with Nginx? [outdated and replaced by Barracuda & Octopus]

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
omega8cc's picture

NOTE: this is an old thread, with now outdated information regarding using Nginx with Aegir. While as a standalone Nginx configuration it may still work fine, it was greatly improved in the meantime and now Nginx is natively supported in Aegir, no more hacks/patches etc. You can install (and upgrade) Aegir based on Nginx, with all enhancements thanks to available now Barracuda & Octopus installers, hosted on GitHub and Gitorious: https://github.com/omega8cc/nginx-for-drupal and http://gitorious.org/aegir/barracuda-octopus.

--------

The shortest answer is: YES.

But, you need a few important ingredients to enjoy your Aegir Hosting System with Nginx as a webserver:

* Latest 0.8.x Nginx installed - try_files required - introduced in 0.7.27 http://nginx.net/CHANGES
* Nginx catch-all configuration with Boost integration (in case Varnish is too powerful for you)
* Simple patch for provision_apache.drush.inc - see http://omega8.cc/dev/provision.diff.txt
* Easy to understand and use Aegir directories tree.

If you prefer standard locations explained in Aegir Documentation then just change them also in the above patch and in the attached below Nginx configuration.

Here it is - sample Nginx configuration to run Aegir Hosting System without the need to restart/reload your fast, small and powerful webserver (please remember to use /bin/true for Apache restart command during Aegir installation).

Please note that I only added some required details for Aegir setup and credit for this Nginx example configuration goes to Brian Mercer. See also where it all started.

In below example Nginx is listening on port 88 since port 80 is used by Pound/Nginx load balancer or Varnish/Ncache fast proxy.

#######################################################
###  nginx.conf  BEGIN
#######################################################
#
pid                   /var/run/nginx.pid;
user                  www www;
worker_processes      4;
worker_rlimit_nofile  8192;

events {
    worker_connections  4096;
    use epoll;
}

http {
## MIME types
  include            /etc/nginx/fastcgi.conf;
  include            /etc/nginx/mime.types;
  default_type       application/octet-stream;

## Size Limits
  client_body_buffer_size         1k;
  client_header_buffer_size       1k;
  client_max_body_size           10m;
  large_client_header_buffers   3 3k;
  connection_pool_size           256;
  request_pool_size               4k;
  server_names_hash_bucket_size  128;

## Timeouts
  client_body_timeout             60;
  client_header_timeout           60;
  keepalive_timeout            75 20;
  send_timeout                    60;

## General Options
  ignore_invalid_headers          on;
  limit_zone gulag $binary_remote_addr 1m;
  recursive_error_pages           on;
  sendfile                        on;
  set_real_ip_from        0.0.0.0/32;
  real_ip_header     X-Forwarded-For;

## TCP options 
  tcp_nodelay on;
  tcp_nopush  on;

## Compression
  gzip              on;
  gzip_buffers      16 8k;
  gzip_comp_level   9;
  gzip_http_version 1.1;
  gzip_min_length   10;
  gzip_types        text/plain text/css image/png image/gif image/jpeg application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon;
  gzip_vary         on;
  gzip_static       on;
  gzip_proxied      any;
  gzip_disable      "MSIE [1-6]\.";

## Log Format
  log_format        main '"$http_x_forwarded_for" $host [$time_local] '
                         '"$request" $status $body_bytes_sent '
                         '$request_length $bytes_sent "$http_referer" '
                         '"$http_user_agent" $request_time "$gzip_ratio"';

  client_body_temp_path /var/cache/nginx/client_body_temp 1 2;
  access_log                   /var/log/nginx/access.log main;
  error_log                     /var/log/nginx/error.log crit;
     
#######################################################
###  nginx.conf catch-all
#######################################################

  server {
        limit_conn   gulag 10;
        listen       127.0.0.1:88;
        server_name  _;
        root         /data/u/$host/;
        index        index.php index.html;

    ## Deny some crawlers
    if ($http_user_agent ~* (HTTrack|HTMLParser|libwww) ) {
         return 444;
    }
    ## Deny certain Referers (case insensitive)
      if ($http_referer ~* (poker|sex|girl) ) {
        return 444;
    }
    ## www. redirect
    if ($host ~* ^(www\.)(.+)) {
        set $rawdomain $2;
        rewrite ^/(.*)$  http://$rawdomain/$1 permanent;
    }
   
    ##
    ## required only when using purl, spaces & og for modules: ajax_comments, watcher and fasttoggle
    ## the /og path should be modified to match your default for og/purl URL for organic groups
    ##
    location ~* ^/og {
        rewrite ^/og\-(.*)/ajax_comments/(.*)$                  /index.php?q=ajax_comments/$2 last;
        rewrite ^/og\-(.*)/context/ajax-block-view$             /index.php?q=context/ajax-block-view last;
        rewrite ^/og\-(.*)/comment/reply/(.*)\?reload=1$        /index.php?q=comment/reply/$2&reload=1 last;
        rewrite ^/og\-(.*)/node/([0-9]+)/toggle/(.*)$           /index.php?q=node/$2/toggle/$3 last;
        rewrite ^/og\-(.*)/node/([0-9]+)/edit\?(.*)$            /index.php?q=node/$2/edit?$3 last;
        rewrite ^/og\-(.*)/user/([0-9]+)/watcher/toggle/(.*)$   /index.php?q=user/$2/watcher/toggle/$3 last;
        rewrite ^/(.*)$                                         /index.php?q=$1 last;
    }

    ## 6.x starts
    location / {
       #rewrite ^/(.*)/$ /$1 permanent; # remove trailing slashes - disabled
        try_files $uri @cache;
    }

    location @cache {
        if ( $request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }
        if ($http_cookie ~ "DRUPAL_UID") {
            return 405;
        }
        error_page 405 = @drupal;
        add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";       
        add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
        add_header X-Header "Boost Citrus 1.9";              
        charset utf-8;
        try_files /cache/normal/$host${uri}_$args.html /cache/$host${uri}_$args.html @drupal;
    }

    location @drupal {
        ###
        ### now simplified to reduce rewrites
        ###
        rewrite ^/(.*)$  /index.php?q=$1 last;
    }

    location ~* (/\..*|settings\.php$|\.(htaccess|engine|inc|info|install|module|profile|pl|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(Entries.*|Repository|Root|Tag|Template))$ {
        deny all;
    }

    location ~* /files/.*\.php$ {
        return 444;
    }
    location ~* /themes/.*\.php$ {
        return 444;
    }
      
    location ~ \.php$ {
          try_files $uri @drupal;       #check for existence of php file
          fastcgi_pass 127.0.0.1:9000;  #php-fpm listening on port 9000
          fastcgi_index index.php;
    }

    location ~ \.css$ {
        if ( $request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }
        if ($http_cookie ~ "DRUPAL_UID") {
            return 405;
        }
        error_page 405 = @uncached;
        access_log  off;
        expires  max; #if using aggregator
        add_header X-Header "Boost Citrus 2.1";
        try_files /cache/perm/$host${uri}_.css /cache/$host${uri}_.css $uri =404;
    }
   
    location ~ \.js$ {
        if ( $request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }
        if ($http_cookie ~ "DRUPAL_UID") {
            return 405;
        }
        error_page 405 = @uncached;
        access_log  off;
        expires  max; # if using aggregator
        add_header X-Header "Boost Citrus 2.2";              
        try_files /cache/perm/$host${uri}_.js /cache/$host${uri}_.js $uri =404;
    }

    location ~ \.json$ {
        if ( $request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }
        if ($http_cookie ~ "DRUPAL_UID") {
            return 405;
        }
        error_page 405 = @uncached;
        access_log  off;
        expires  max; # if using aggregator
        add_header X-Header "Boost Citrus 2.3";              
        try_files /cache/normal/$host${uri}_.json /cache/$host${uri}_.json $uri =404;
    }

    location @uncached {
        access_log  off;
        expires  max; # max if using aggregator, otherwise sane expire time
    }

    location ~* /files/imagecache/ {
        access_log         off;
        try_files $uri @drupal;  #imagecache support - now it works
    }

    location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
        access_log      off;
        expires         30d;
        try_files $uri =404;
    }

    location ~* \.xml$ {
        if ( $request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }
        if ($http_cookie ~ "DRUPAL_UID") {
            return 405;
        }
        error_page 405 = @drupal;
        add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
        add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
        add_header X-Header "Boost Citrus 2.4";              
        charset utf-8;
        types { }
        default_type application/rss+xml;
        try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html /cache/$host${uri}_.xml $uri @drupal;
    }

    location ~* /feed$ {
        if ( $request_method !~ ^(GET|HEAD)$ ) {
            return 405;
        }
        if ($http_cookie ~ "DRUPAL_UID") {
            return 405;
        }
        error_page 405 = @drupal;
        add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
        add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
        add_header X-Header "Boost Citrus 2.5";              
        charset utf-8;
        types { }
        default_type application/rss+xml;
        try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html /cache/$host${uri}_.xml $uri @drupal;
    }

  } # end of server

#######################################################
###  nginx.conf catch-all
#######################################################

}

And /etc/nginx/fastcgi.conf looks similar to:

# fastcgi.conf
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    ApacheSolaris/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

fastcgi_index  index.php;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

Example of custom nginx build:

cd /var/opt
wget http://sysoev.ru/nginx/nginx-0.8.31.tar.gz &&
tar -xzf nginx-0.8.31.tar.gz &&
cd nginx-0.8.31 &&
./configure --prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=www \
--group=www \
--with-http_realip_module \
--with-rtsig_module \
--with-http_gzip_static_module \
--with-debug \
--with-http_stub_status_module \
--with-http_ssl_module \
--without-mail_pop3_module \
--without-mail_imap_module \
--without-mail_smtp_module \
--without-http_ssi_module \
--without-http_auth_basic_module \
--without-http_geo_module \
--http-client-body-temp-path=/var/cache/nginx/client_body_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp &&
make &&
make install
cd ./../
service nginx stop
killall -9 nginx
service nginx start

Example of custom php-fpm build:

cd /var/opt
tar -xzf php-5.2.11.tar.gz &&
tar -xzf php-fpm-0.6-5.2.11.tar.gz &&
sh php-fpm-0.6-5.2.11/generate-fpm-patch &&
gzip -d suhosin-patch-5.2.11-0.9.7.patch.gz
cd /var/opt/php-5.2.11
patch -p 1 -i ../suhosin-patch-5.2.11-0.9.7.patch
patch -p1 < ../fpm.patch

./buildconf --force
mkdir fpm-build && cd fpm-build

../configure --with-fpm \
--enable-fastcgi \
--with-mysql \
--with-mysqli \
--enable-force-cgi-redirect \
--enable-discard-path \
--with-zlib \
--with-curl \
--with-curlwrappers \
--with-gd \
--with-jpeg-dir=/usr/lib \
--with-pear \
--with-imap \
--with-imap-ssl \
--with-openssl \
--with-pdo-mysql \
--enable-soap \
--enable-ftp \
--enable-mbstring \
--enable-pcntl \
--enable-bcmath \
--with-kerberos \
--with-xsl \
--with-mcrypt &&
make &&
make install
cd ./../

~Grace

Comments

Thanks for config, its work

dicreat's picture

Thanks for config, its work fine for me, expect one little problem - when I click "Administer" (link with URL /admin) I'm getting the content of /index.php (in site root directory). But all others links work fine - admin/build and etc. I' really don't know why...

@dicreat

omega8cc's picture

Are you using php-fpm for PHP/FastCGI ?

~Grace -- Turnkey Drupal Hosting on Steroids -- http://omega8.cc

omega8cc, my problem gone

dicreat's picture

omega8cc, my problem gone away and now all work fine.
Thanks!

superxain's picture

I want to know whether I shall use "fastcgi_param REDIRECT_STATUS 200"

I've wondered about that line

brianmercer's picture

I've wondered about that line in fastcgi_conf also.

My understanding is that it was a security feature for php-cgi that prevented .php files from being run directly from a URL (i.e. http:example.com/cgi-bin/example.php) by requiring that the "REDIRECT_STATUS 200" parameter be passed from the web server, typically in an apache rewrite.

I've commented it out and .php files still run fine, so I don't think the feature is commonly enabled if it even works with fastcgi these days.

I've wondered about that line

brianmercer's picture

NT

I didn't tried PHP 5.3 on any

omega8cc's picture

I didn't tried PHP 5.3 on any production server, but if this comment is true, then

fastcgi_param  REDIRECT_STATUS    200;

can be still valid.

"It appears that as of 5.3.0, --enable-force-cgi-redirect is not a valid configure option. A quick review of the 5.3.0 code indicates that it the logic previously enabled by specifying the --enable-force-cgi-redirect configure option is being built into php by default."

~Grace

Update

omega8cc's picture

Added examples for custom nginx and php-fpm build.

~Grace -- Drupal on Steroids -- http://omega8.cc

Note: nginx/0.7.62 comes with

Carl Johan's picture

Note: nginx/0.7.62 comes with ubuntu 9.10 karmic koala and has support for try_files

Thx for the configs,

brianmercer's picture

Thx for the configs, omega8cc. I've been using the jeff waugh repos compiled for hardy.
I just installed fcgiwrap to let me mess with awstats and nagios using just nginx and php5-cgi. I'm going to work on collectd next.

Configuration Update

omega8cc's picture

Added/Fixed:

  1. latest Boost compatibility for /cache/normal & /cache/perm
  2. json cache for Boost
  3. fix for xml/feed Boost cache files with .html extension
  4. fix for xml/feed Boost cache correct mime type

~Grace -- Drupal on Steroids -- http://omega8.cc

Update for Aegir/provision patch

omega8cc's picture

To revert Apache-only latest Aegir changes, so it is still possible to use Nginx with latest Aegir 0.4 alpha3.

http://omega8.cc/dev/provision.patch.txt

~Grace -- Drupal on Steroids -- http://omega8.cc

Nginx as reverse proxy for Apache

manogolf's picture

If I had the courage I would setup Aegir on Nginx following your instructions but that's for another day. For now I would like to use Nginx as a proxy for the usual static content but am unable to make it work with Aegir created sites.

Am I starting off rudely and inappropriate? This was the only post I could find that was remotely related to Aegir and Nginx. Bounce me along without hesitation if so.

If not out of line perhaps you might help me understand a way to make these two play together.
I see examples for user as www www and/or www data. Which is correct?
Root is really throwing me. Do you proceed identifying the path through the platform down to domain.com or stop at platform, /var/aegir/platform/6.14 or /var/aegir/platform/6.14/sites/example.com
I can't get either to work but knowing which is correct would help. Or use /var/aegir or ???

Any help is appreciated.

@manogolf

omega8cc's picture

Aegir setup for Nginx is different than Apache and it will not work together. You have to use only one kind of webserver with single Aegir instance.

~Grace

A few updates to above Nginx

omega8cc's picture

A few updates to above Nginx configuration example:

  1. Added custom fix required only when using purl, spaces & og for modules: ajax_comments, watcher and fasttoggle
  2. Simplified rewrite rules for location @drupal resolves also some problems with imagecache
  3. Changed order of try_files for Boost to match newer version of dirs structure first

~Grace

Would be nice to have this

crea's picture

Would be nice to have this config in VCS so we could submit patches

@crea

omega8cc's picture

Good idea.

Nginx configuration for Drupal and Aegir - Project on GitHub. Please file issues, post patches and improvements on the GitHub issue tracker.

~Grace

Which PHP configure options

rokape's picture

Which PHP configure options should I use before compiling?

What about path of my site in

rokape's picture

What about path of my site in nginx.conf.....
I use path my site same apache: /home/use../public_html/ ?

And config with boost?

rokape's picture

And config with boost?

I use this sitting but when

rokape's picture

I use this sitting but when start nginx ,it said:
duplicate location "/" in

## 6.x starts
location / {
#rewrite ^/(.*)/$ /$1 permanent; # remove trailing slashes - disabled
try_files $uri @cache;
}

I've don't site with drupal

rokape's picture

I've don't site with drupal on nginx but load very slow,css not loaded....What' wrong?

Thanks for sharing this

devmobdev's picture

Thanks for sharing this information. I got a chance to know about this.
Only local images are allowed.Only local images are allowed.Only local images are allowed.

Thanks....I've done with

rokape's picture

Thanks....I've done with this.Work like a charm...How to redirect con-www-> www?

FCK editor say erro 404 for

rokape's picture

FCK editor say error 404 for file?:
Error loading "sites/all/modules/fckeditor/fckeditor/fckstyles.xml" (HTTP Status: 404).

Do you want to see the server response dump?

There is a fix for FCKeditor

omega8cc's picture

There is a fix for FCKeditor uploaded just a minute ago, see http://github.com/omega8cc/nginx-for-drupal

Also, please don't spam this group with random comments, since it seems you are asking for help without doing your homework and without including information required to help you. Sorry if that sounds not too friendly, but it is in the best interest also for you to use groups on g.d.o without spam-like requests.

~Grace

@rokape - you seem to be

yhager's picture

@rokape - you seem to be talking to yourself. Please be more civil, do some experimenting, and then write an informative message. This way you make the opposite of making people want to help you.

Also - it is not clear which project you are reporting those issues on. If it is on github, use github issue queue, if it is not, please include enough information for people to understand.

And above all - be patient. If you are looking for fast response times - seek for paid help - otherwise you are dependent on the good will of people in this group.

Aegir install fails at step 4 "Set Up Database"

Th30philus's picture

First, I'm not sure what directory the nginx.conf is supposed to point to. Where is "root /data/u/$host/;" supposed to point to? I understand this is a variant of the standard aegir install, but what is it replacing?

I pointed the nginx root to "/var/aegir/hostmaster-0.4-alpha5/sits/$host/;" but this only returned a server 500 error.

Second, if I point the nginx root to "/var/aegir/hostmaster-0.4-alpha5/;" I get the Aegir install in my browser, but when it gets to step 4, "Set Up Database" it fails.

I created the mysql database and user per the install.txt instructions. I enter the mysql database "aegir" the user "aegir" with the password for that user on the Database configuration page (just like mig5 shows on his video http://www.mig5.net/content/video-installing-aegir-04-alpha5 ), but when I press "Save and Continue" the setup does not progress to step 5 "Install Profile". Instead the page simply refreshes on step 4, asking again for the database name, user name and password -- no errors are reported.

Any idea what's going on here?

Fixed -- Aegir install fails at step 4 "Set Up Database"

Th30philus's picture

Out of frustration, I wiped my vps, and started over again from scratch. Same problem. Everything seemed to work until I get to step 4.

I tried changing the aegir mysql password, but then I got MYSQL access denied error.

I restarted mysql, but the Aegir installation returned to the same refreshing step 4 problem.

I rebooted the server, and now everything seems to be working. I'm not exactly sure why, but that's what I did, for the record.

This "refreshing step 4

omega8cc's picture

This "refreshing step 4 problem" is probably because you have enabled opcode caching, like APC. Try to install the Aegir system with APC disabled, or at least, when that happens, reload php-fpm daemon to clear the php cache and refresh the page in your browser - it will continue the install without further issues.

That /data/u/$host/ is for

omega8cc's picture

That /data/u/$host/ is for catch-all nginx configuration for Aegir. It's related to the provision patch. You can change it in both nginx config and provision patch to meet your requirements.

Thanks for the great

llite's picture

Thanks for the great post!

Just to share my two cents. If someone wants to limit the internal search enquiries, here is my my extra:

limit_req_zone $binary_remote_addr zone=search:10m rate=1r/s;

location /search/ {
limit_req zone=search burst=3;

try_files $uri @drupal;
}

It looks like a good security

omega8cc's picture

It looks like a good security add-on, especially for bigger sites using native Drupal search only.

Thanks!

Provision Patch Compatibility

lukus's picture

Hi - thanks for the great write up. Really appreciate all the work that must have gone into this.

I now have my server environment setup, and I've successfully run the initial aegir installation script, but I've come up against a problem patching using the provision.patch from github.

After trying to apply the patch from the root of my aegir directory, I'm provided with the following message:

patching file provision/platform/provision_drupal_settings.tpl.php
Hunk #1 succeeded at 9 with fuzz 2 (offset 8 lines).
Hunk #2 succeeded at 53 (offset 10 lines).
patching file provision/web_server/provision_apache.drush.inc
Hunk #1 FAILED at 213.
1 out of 1 hunk FAILED -- saving rejects to file provision/web_server/provision_apache.drush.inc.rej

The install script provided the following info:

AEGIR_VERSION=0.4-alpha7
AEGIR_HOME=/var/aegir
WEB_GROUP=www-data
HOSTMASTER_DIR=/var/aegir/hostmaster-0.4-alpha7

Is the patch no longer compatible with this version?

We are working now on proper

omega8cc's picture

We are working now on proper nginx implementation in the dev Aegir branch: dev-services, so it should be improved soon, and I will update also this old setup on github, but for now please use working patch available here:

http://omega8.cc/dev/provision.diff.txt

I have updated also the link to the working patch in this recipe above. Thanks.

HTH

Thanks very much - worked

lukus's picture

Thanks very much - worked perfectly :)

Hi again I now have my aegir

lukus's picture

Hi again

I now have my aegir installation up and running - and I'm impressed. It's a really nice, logical solution.

I'm using your catchall config nginx.conf, which I think works well. As you rightly mentioned, using this setup is great because the webserver doesn't need to be restarted each time a new domain is added.

While everything's working, I'm a bit unsure about my configuration:

  • As I'm not using /data/u/[hostname] for my web root directory on my server, I've just adjusted the path to point to a subdirectory in /var/www/.
  • I'm then manually creating symbolic links within this directory, to point each domain to its required codebase (depending on the package I've chosen);
  • e.g.
    aegir.example.com -> /var/aegir/hostmaster-0.4-alpha7/
    example1.com -> /var/aegir/platforms/pressflow-6/
    example2.com -> /var/aegir/platforms/pressflow-6/
    example3.com -> /var/aegir/platforms/atrium-1-0-beta6/

This works - but I've got a nagging feeling that I might be missing something - especially since aegir is diligently creating vhost entries in /var/aegir/config/vhost.d.

Would you recommend that I do this differently?

The config files created by

omega8cc's picture

The config files created by Aegir for Apache are not used, so leave them as is, it doesn't matter. However when adjusting paths, make sure that this line:

http://github.com/omega8cc/nginx-for-drupal/blob/master/nginx.conf#L78

matches this:

http://github.com/omega8cc/nginx-for-drupal/blob/master/provision.patch#L47

With this patch you don't need to create symlinks manually, since provision will do that for you with every site install or rename, but please make sure your Aegir user has write access to /var/www/

HTH ~Grace

[EDIT] The line in provision patch refers to (not working now) github version only for reference, while the working patch (to be edited if you are using different directory for your symlinks) is now available here.

Hello again - is it possible

lukus's picture

Hello again - is it possible to use

 
  auth_basic            "Restricted";
  auth_basic_user_file  conf/htpasswd;

with the nginx catchall configuration?

If it is - how would you suggest this was implemented on a per site basis?

EDIT:

I didn't realise that extra server definitions could exist below the catch all. I've achieved a possible solution, by duplicating server definition that's used for the catch-all for a specific domain, where I've added the auth_basic configuration options underneath the 'location /' definition. It's not pretty - but it works.

What is @drupal in

mikeshn's picture

What is @drupal in nginx.conf? How it's define?

We should add handling to

meatbag's picture

We should add handling to '/boost-gzip-cookie-test.html' which's needed by Boost.

This line in htaccess might change

mikeytown2's picture

I need to give some time to this issue. I would put more effort into the cookie enabling gzip rather then a simple redirect.
http://drupal.org/node/764494

Events Module Choice

xkind's picture

I noticed you have
--with-rtsig_module
as an option to the configure command,
but then you have
use epoll;
in the nginx.conf file.

Were you comparing events options before you settled on epoll?

I'm running CentOS 5.5 based on the 2.6.18 linux kernel, so I assume my default is going to be epoll, and that it will be the best option for me.

It is no longer used in

omega8cc's picture

It is no longer used in Barracuda: https://github.com/omega8cc/nginx-for-drupal. Probably something left there before during tests etc. Thanks!

gzip_types

wobbler's picture

This example conf file is great, although I think having image/png image/gif and image/jpeg in the gzip_types means that nginx will compress image files for transfer... doesn't make sense as most image files are by nature already pretty well compressed. I tried compressing a few different image files and found that some actually went up in size eg. nearly 1k on an 8k png file.

Having gzip set to level 9 means that the server is spending memory and cpu cycles trying very hard to compress virtually uncompressible files, then when the browser receives them it has to also spend time to uncompress them for negligible gains or worse performance loss at both server and client end.

Look at the following benchmark, it shows that although you may get a bit better compression ratio level 9 takes pretty much 6 times longer than level one to process. http://tukaani.org/lzma/benchmarks.html

You should consider taking the images out of the gzip_types and changing the compression level to a lower value (probably 1).

Good catch, thanks! It is now

omega8cc's picture

Good catch, thanks! It is now changed in this commit: http://bit.ly/fTKO4s. I believe it was just a result of some YSlow tests performed long time ago (as far as I remember, it gives you higher rank when you compress also images), and we forgot to remove it later.

np. when your server is as

wobbler's picture

np. when your server is as slow as mine I need every drop of memory and every cpu cycle available!

Cached css and js

wobbler's picture

I know this is an old thread, but I checked the git repo and think that it is still the same.

Looking at mikey's latest htaccess there is no test for DRUPAL_UID or non GET header for serving css and js files from the boost cache directory, only html, xml and json files. If the css or js files exist in the boost cache directory they would be served.

In these nginx conf files there is a test, so a logged in user would not be served the css or js from boost cache directory they would be served the file from the normal drupal cache directory. In reality these files are the same, although if you have gzip_static and boost has generated the gz version then you would gain some performance for logged in users.

This isn't the end of the world, just a comment that it is not directly equivalent to the htaccess functionality. I don't know if mikey may at sometime rely on that logic for something.

changes

mikeytown2's picture

I've come up with a better way to do css & js file caching htaccess rules.
http://drupal.org/node/1040534#comment-4026846

I hope to take the 4 rules we currently have and reduce it down to 3; 2 for gzip (type needs to be set) one without gzip. This would be a old rules compatibility breaking move as I would no longer use _.js or _.css for js/css files in the perm dir. The different rules do not conflict with each other so migration shouldn't be that painful. I would do this change after the next release. so if the next boost release is 1.19; change would go in 1.20 if the change does go in.

I'm always looking for ways to reduce complexity; you can build complex systems on top of a simple base.

Mike

omega8cc's picture

This is a side note, but I just realized I made as deprecated this thread you are linking to for Nginx + Boost configuration. I will post a standalone Nginx+Boost configuration shortly and will let you know the URL to the new thread here.

Thanks for this - I found it

snowmountain's picture

Thanks for this - I found it very useful.

I notice the nginx config is for Drupal 6; I used some of the code and got boost caching to work for Drupal 7, but I was wondering if there is a version of the nginx config for Drupal 7?

Re: changes in the next Boost releases

omega8cc's picture

OK, I will take a look and will check what/how should we change.

It is by design in our

omega8cc's picture

It is by design in our configuration, as we assume that logged is users should never use any files cached by Boost, including css and js, as it can cause issues when you are working on your themes etc.

Fair enough

wobbler's picture

Yeah, I realise it may not make sense, was just pointing out that the logic didn't exactly match the latest htaccess files... if the content of the css and js files changes doesn't drupal change the filename? or is that only when the cache is cleared?

Yes, Drupal (maybe) changes

omega8cc's picture

Yes, Drupal (maybe) changes the filenames, but only when you have css/js aggregation enabled, while when you are working on themes, you probably have aggregation disabled, hence the css/js filenames don't change.

Aegir

walterbagehot's picture

First of all, Egir's very much designed to work within Drupal's multisite structure. Often one of the biggest hurdles users experience when trying to learn Egir.Just wanted to thank you for your very well-written documentation complete with screenshots.
hotels near disneyland

That always helped a lot.

panama homes's picture

Yes it is an old thread. But everytime time, I needed help in using Nginx with Aegir, it helped me.
So thank you to all for that great help.
panama real estate

Has anyone ever install aegir

elvis2's picture

Has anyone ever install aegir (barracuda) on a Solaris 11 OS? We are looking into using Joyent's SmartOS and wanted to confirm that someone else has setup aegir successfully in this environment?

Nginx

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: