Skip to content

Instantly share code, notes, and snippets.

@jney
Created March 29, 2009 14:20
Show Gist options
  • Save jney/87416 to your computer and use it in GitHub Desktop.
Save jney/87416 to your computer and use it in GitHub Desktop.
# user and group to run as
user www www;
# pid of nginx master process
pid /var/run/nginx.pid;
# number of nginx workers
worker_processes 6;
# Number of worker connections. 1024 is a good default
# Max client is equal to worker_connections * worker_processes
events {
worker_connections 1024;
}
# start the http module where we config http access.
http {
server_names_hash_bucket_size 128;
# pull in mime-types. You can break out your config
# into as many include's as you want to make it cleaner
include /usr/local/etc/nginx/mime.types;
# set a default type for the rare situation that
# nothing matches from the mime-type include
default_type application/octet-stream;
# configure log format
log_format main '$remote_addr (for $http_x_forwarded_for) [$time_local] '
'"$http_host" "$request" $status $body_bytes_sent (from "$http_referer") '
'"$http_user_agent"';
# main access log
access_log /var/log/nginx-access.log main;
# main error log
error_log /var/log/nginx-error.log notice;
# These are good default values.
sendfile on;
tcp_nopush on;
tcp_nodelay off;
keepalive_timeout 70;
# output compression saves bandwidth
gzip on;
# gzip_http_version 1.0;
gzip_comp_level 9;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_min_length 1100;
gzip_types text/plain text/html text/css text/javascript;
gzip_types application/x-javascript text/xml application/xml application/xml+rss application/atom+xml;
gzip_disable "MSIE[1-6]\.~SV1\.";
# this is where you define your mongrel clusters.
# you need one of these blocks for each cluster
# and each one needs its own name to refer to it later.
#upstream fonzz {
# server 127.0.0.1:8000;
# server 127.0.0.1:8001;
# server 127.0.0.1:8002;
# server 127.0.0.1:8003;
# server 127.0.0.1:8004;
#}
upstream fonzz {
server unix:/var/run/thin.0.socket;
server unix:/var/run/thin.1.socket;
server unix:/var/run/thin.2.socket;
}
proxy_next_upstream error timeout;
proxy_read_timeout 30;
upstream horoscope {
server 127.0.0.1:8010;
server 127.0.0.1:8011;
server 127.0.0.1:8012;
}
upstream alphonse {
server 127.0.0.1:8020;
server 127.0.0.1:8021;
server 127.0.0.1:8022;
}
# This server is just handling queries on the IP (usually hackers)
server {
listen 80;
root /var/empty;
access_log /var/log/nginx-dummy.access_log main;
error_log /var/log/nginx-dummy.error_log info;
}
# the server directive is nginx's virtual host directive.
server {
# port to listen on. Can also be set to an IP:PORT
listen 80;
# Set the max size for file uploads to 50Mb
client_max_body_size 50M;
# sets the domain[s] that this vhost server requests for
server_name en.fonzz.com fr.fonzz.com www.fonzz.com fonzz.com;
# doc root
root /usr/local/fonzz/www/public;
# vhost specific access log
access_log /var/log/nginx-fonzz-access.log main;
# vhost specific error log
error_log /var/log/nginx-fonzz-error.log notice;
# If the URL has not been prefixed, adding the www at the beginning
if ($host ~* ^fonzz\.com$) {
rewrite ^.+ http://www.fonzz.com$uri permanent;
break;
}
# this rewrites all the requests to the maintenance.html
# page if it exists in the doc root.
if (-f $document_root/maintenance.html) {
return 503;
}
error_page 503 @503;
location @503 {
rewrite ^(.*)$ /maintenance.html break;
}
# Remove IE \"
#if ($args ~ ^([^\"]+)\"(.*)$) { set $args $1%22$2; }
#if ($args ~ ^([^\"]+)\"(.*)$) { set $args $1%22$2; }
#if ($args ~ ^([^\"]+)\"(.*)$) { set $args $1%22$2; }
#if ($args ~ ^([^\"]+)\"(.*)$) { set $args $1%22$2; }
#if ($args) {
# rewrite ^/(.*) /$1?$args last;
#}
location / {
#set $memcached_key $uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
# Add expires header for static content
if (-f $request_filename) {
expires max;
break;
}
if (!-f $request_filename) {
proxy_pass http://fonzz;
break;
}
}
# Legal notices & terms of services
# In English
location /legal_en.html {
root /usr/local/fonzz/www/public/html;
}
# In French
location /legal_fr.html {
root /usr/local/fonzz/www/public/html;
}
error_page 404 = 404.html;
location = /404.html {
root /usr/local/fonzz/www/public;
}
error_page 500 502 504 500.html;
location = /500.html {
root /usr/local/fonzz/www/public;
}
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|mov)$ {
root /usr/local/fonzz/www/public/;
}
}
# the server directive is nginx's virtual host directive.
server {
# port to listen on. Can also be set to an IP:PORT
listen 80;
# Set the max size for file uploads to 50Mb
client_max_body_size 50M;
# sets the domain[s] that this vhost server requests for
server_name horoscope-astrologique.fr www.horoscope-astrologique.fr;
# doc root
root /usr/local/www/horoscope;
# vhost specific access log
access_log /var/log/nginx-horoscope-access.log main;
# vhost specific error log
error_log /var/log/nginx-horoscope-error.log notice;
# If the URL has not been prefixed, adding the www at the beginning
if ($host ~* ^horoscope-astrologique\.fr$) {
rewrite ^.+ http://www.horoscope-astrologique.fr$uri permanent;
break;
}
location / {
set $memcached_key horoscope-production:$host$uri;
memcached_pass 127.0.0.1:11211;
default_type text/html;
error_page 404 = @fallback;
#sub_filter "l<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
# '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
#sub_filter_once on;
}
location @fallback {
proxy_set_header X-Real-IP $remote_addr;
# Add expires header for static content
if (-f $request_filename) {
expires max;
break;
}
if (!-f $request_filename) {
proxy_pass http://horoscope;
break;
}
}
}
# the server directive is nginx's virtual host directive.
server {
# port to listen on. Can also be set to an IP:PORT
listen 80;
# Set the max size for file uploads to 50Mb
client_max_body_size 50M;
# sets the domain[s] that this vhost server requests for
server_name alphonse-annonce.com www.alphonse-annonce.com;
# doc root
root /usr/local/www/alphonse;
# vhost specific access log
access_log /var/log/nginx-alphonse-access.log main;
# vhost specific error log
error_log /var/log/nginx-alphonse-error.log notice;
# If the URL has not been prefixed, adding the www at the beginning
if ($host ~* ^alphonse-annonce\.com$) {
rewrite ^.+ http://www.alphonse-annonce.com$uri permanent;
break;
}
location / {
set $memcached_key alphonse-production:$host$uri;
memcached_pass 127.0.0.1:11211;
default_type text/html;
error_page 404 = @fallback;
}
location @fallback {
#location / {
proxy_set_header X-Real-IP $remote_addr;
# Add expires header for static content
if (-f $request_filename) {
expires max;
break;
}
if (!-f $request_filename) {
proxy_pass http://alphonse;
break;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment