nginx 그림 서버 설정

3093 단어
user  nginx;
 
 worker_processes 8;
 
error_log  /usr/local/webserver/nginx/logs/nginx_error.log  crit;
 
pid        /usr/local/webserver/nginx/nginx.pid;
 
#Specifies the value for maximum file descriptors that can be opened by thisprocess.
worker_rlimit_nofile 65535;
 
events
{
  use epoll;
  worker_connections 65535;
}
 
http
{
  include       mime.types;
  default_type  application/octet-stream;
 
  charset  utf-8;
 
  server_names_hash_bucket_size 128;
  client_header_buffer_size 32k;
  large_client_header_buffers 4 32k;
  client_max_body_size 300m;
 
  sendfile on;
  tcp_nopush     on;
 
  keepalive_timeout 60;
 
  tcp_nodelay on;
 
  client_body_buffer_size  512k;
  proxy_connect_timeout    5;
  proxy_read_timeout       60;
  proxy_send_timeout       5;
  proxy_buffer_size        16k;
  proxy_buffers            4 64k;
  proxy_busy_buffers_size 128k;
  proxy_temp_file_write_size 128k;
 
  gzip on;
  gzip_min_length  1k;
  gzip_buffers     4 16k;
  gzip_http_version 1.1;
  gzip_comp_level 2;
  gzip_types       text/plainapplication/x-javascript text/css application/xml;
  gzip_vary on;
 
  # :proxy_temp_path proxy_cache_path            
  proxy_temp_path   /data0/proxy_temp_dir;
  #  Web      cache_one,         200MB,1             ,         5GB。
  proxy_cache_path  /data0/proxy_cache_dir  levels=1:2   keys_zone=cache_one:200m inactive=1d max_size=5g;
 
   
  server #        
  {
    listen       80;
    server_name  your_server_ip;
 
    location /
    {
         proxy_cache cache_one;
         #    HTTP            
         proxy_cache_valid  200 304 12h;
         #   、URI、     Web   Key ,Nginx  Key   ,              
         proxy_cache_key  $host$uri$is_args$args;
         proxy_set_header Host  $host;
         proxy_set_header X-Forwarded-For  $remote_addr;
         proxy_pass http://your_server_ip:8080; #             
 
log_format cache '***$time_local '
 
                    '$upstream_cache_status '
 
                    'Cache-Control: $upstream_http_cache_control '
 
                    'Expires: $upstream_http_expires '
 
                    '"$request" ($status) '
 
                    '"$http_user_agent" '; #      (         hit miss ,         ,       ,     ,        )
 
                  access_log  /var/log/nginx/cache.log cache; #        
 
 
         expires      1d;
    }
 
    #      ,    URL http://192.168.8.42/test.txt,    http://192.168.8.42/purge/test.txt      URL   。
    location ~ /purge(/.*)
    {
     #        IP IP      URL  。
     allow            127.0.0.1;
     deny            all;
     #proxy_cache_purge   cache_one$host$1$is_args$args;
    }
 
    #    .php、.jsp、.cgi            。
    location ~ .*\.(php|jsp|cgi)?$
    {
         proxy_set_header Host  $host;
         proxy_set_header X-Forwarded-For  $remote_addr;
    }
 
    access_log  off;
  }
 
#        
server
{
  listen 8080;
 
  server_name your_server_ip;
 
  location /
  {
    root /;
 
  }
 
access_log /usr/local/webserver/nginx/logs/nginx_access.log;
 
}
}

좋은 웹페이지 즐겨찾기