FAQ

Page Discussion Edit History

ModulesByExample

[edit] Modules Organized by Example

This is not a functional example. Do not use it as a starting point for your own configuration. The values given might not be appropriate. It is only meant to be a contextual index into the documentation.

user nginx;
 
daemon on;         # for debugging only
debug_points stop; # for debugging only
master_process on; # for debugging only
 
env PERL5LIB=/usr/local/perl5/modules;
 
pid /var/run/nginx.pid;
lock_file /var/lock/nginx.lock;
error_log /var/log/nginx/errors.log;
log_not_found off;
 
ssl_engine dynamic; 
timer_resolution 100ms;
 
worker_cpu_affinity 0101 1010;
worker_priority on;
worker_processes 2; 
worker_rlimit_core 5M;
worker_rlimit_nofile 8192;
worker_rlimit_sigpending 1024;
working_directory /var/tmp/nginx;
 
include /etc/nginx/sites/*;
 
events {
  use kqueue; 
  worker_connections 4096;
  accept_mutex on;
  accept_mutex_delay 500ms;
  debug_connection 192.168.1.1;
  devpoll_changes 100; # | kqueue_changes 
  devpoll_events 32; # | kqueue_events | epoll_events
  multi_accept off;
  rtsig_signo 40;
  rtsig_overflow_events 16;
  rtsig_overflow_test 32;
  rtsig_overflow_threshold 10;
}
 
http {
  client_body_in_file_only off;
  client_body_buffer_size 16k;
  client_body_temp_path /var/tmp/nginx/client_temp 1 2
  client_body_timeout 60;
  client_header_buffer_size 1k;
  client_header_timeout 60;
  client_max_body_size 1m;
 
  default_type text/html;
  error_page 404 /var/www/html/404.html;
 
  keepalive_timeout 30;
  large_client_header_buffers 4 4k;
 
 
  msie_padding on;
  msie_refresh off;
  optimize_server_names on;
  port_in_redirect on;
  recursive_error_pages off;
  satisfy_any off;
  send_timeout 60;
  sendfile off;
 
  server_name_in_redirect on;
  server_names_hash_max_size 512;
  server_names_hash_bucket_size 32;
  server_tokens on;
 
  tcp_nodelay on;
  tcp_nopush off;
 
  upstream bigapp {
    server 127.0.0.1 weight=5;
    server 127.0.0.1:8080;
    server unix:/tmp/backend3;
  }
 
  server {
    listen 80;  
    server_name www.domain.com domain.com;
 
    root /var/www;
 
    location / {
      index index.html;
    }
 
    location /images {
      limit_rate 100k;
      limit_except GET {
        allow 192.168.1.0/32;
        deny all;
      }
      types {
        image/gif    gif;
        image/jpeg   jpg;
      }
    }
 
    location /myapp {
      try_files index.php index.php5 @fallback;
    }
 
    location @fallback {
      root /var/www/error;
      index index.html;
    }
 
    location /bigapp {
      proxy_pass http://bigapp;
    }
  }
}