It's been a while since I posted my Nginx configuration for TYPO3. It's been updated recently. I run several sites that use similar configuration options, so I split off parts of the configuration into include files.
The main configuration for somesite.org:
server {
listen 109.74.192.51;
server_name somesite.org;
rewrite ^ $scheme://www.somesite.org$request_uri? permanent;
}
server {
listen 109.74.192.51;
server_name www.somesite.org;
set $basename 'somesite.org';
root /var/www/$basename;
include include/expires-typo3.conf;
include include/staticfile-typo3.conf;
include include/php-fastcgi.conf;
}
The expires conf:
location = /favicon.ico {
expires max;
}
location = /clear.gif {
empty_gif;
expires max;
}
location ^~ /typo3/gfx {
expires max;
}
location ^~ /typo3temp/compressor {
expires max;
}
location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)((\?\d\d\d\d\d\d\d\d\d\d)|(\?s=\d\d\d\d\d\d\d\d\d\d))$ {
expires max;
}
location ~* ^(/typo3/sysext|/typo3conf/ext).*\.(cur|ico|gif|png|jpe?g|css|js|swf|woff) {
expires max;
}
location ~* \.(sql|htaccess|htpasswd) {
deny all;
}
location ~* \.(cur|ico|gif|png|jpe?g|css|js|swf|woff)(\?v\d\d?\.\d\d?\.\d\d?)$ {
expires max;
}
The staticfile-typo3.conf:
set $static 1;
if ($http_pragma = 'no-cache') {
set $static 0;
}
if ($http_cache_control = 'no-cache') {
set $static 0;
}
if ($http_cookie = 'nc_staticfilecache|be_typo_user') {
set $static 0;
}
if ($request_method = 'POST') {
set $static 0;
}
if ($query_string) {
set $static 0;
}
if (!-f $document_root/typo3temp/tx_ncstaticfilecache/www.$basename${request_uri}index.html ) {
set $static 0;
}
if ($static = 1) {
rewrite .* /typo3temp/tx_ncstaticfilecache/www.$basename${request_uri}index.html last;
}
location ^~ /typo3temp/tx_ncstaticfilecache {
expires 43200;
charset utf-8;
}
The php-fastcgi.conf:
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fcgid/.fastcgi.www-data/socket;
fastcgi_index index.php;
include fastcgi_params;
}
So, there you have it. Please post comments an suggestions.


I'm doing bench of typo3 using apache+php, nginx+php-fpm, varnish and soon apache+php-fpm and apache+fastcgi-php
Can you please provide any tuning you did on Nginx or the Fastcgi config ?
For example, in /etc/php-fpm.d/www.conf I set :
pm.max_children = 30
(I also tested with pm.max_children = 5) to limit the load on the backend host.
For the moment, I can handle 50 parallel users with a 5 second lattency... better slow than dead host isn't it ?
I can provide graphs results when all tests are done...
I use php-fcgi as it comes with debian. fpm does not. I use as many children as the available memory will allow. Currently about 15.
I did a little tuning on the cgi:
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffers 256 4k;
Otherwise nginx is configured pretty much default, running 6 workers.