1. 程式人生 > >nginx配置備份

nginx配置備份

server {
    listen 80;
    server_name localhost;

    set $expires_duration "30d";
    if ($uri ~* \.html$) {
        set $expires_duration "10m";
    }

    expires $expires_duration;

    location /public/ {
        root /usr/share/nginx/html;
    }

    location /tmp/ {
        root /home/popeye;
    }

    location = /m {
        root /usr/share/nginx/html;
        error_page 404 404.html;
    }

    location /m/ {
        root /usr/share/nginx/html;
        error_page 404 404.html;
    }

    location / {
        root /usr/share/nginx/html/portal;
        error_page 404 404.html;
    }

}
      						
        					

 

worker_processes  4;
worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 65535;
events {
    worker_connections  65535;
    use epoll;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
        log_format log_json '{ "@timestamp": "$time_local", "remote_addr": "$remote_addr", "referer": "$http_referer",'
                        '"request": "$request", "status": $status, "bytes": $body_bytes_sent, "agent": "$http_user_agent", '
                        '"x_forwarded": "$http_x_forwarded_for", "up_addr": "$upstream_addr",'
                        '"up_host": "$upstream_http_host", "up_resp_time": "$upstream_response_time", "request_time": "$request_time"}';
    access_log  logs/access.log  log_json;
    sendfile        on;
    tcp_nopush     on;
    tcp_nodelay on;

    keepalive_timeout  500;
    
    server_names_hash_bucket_size 256;
    client_header_buffer_size 256k;
    large_client_header_buffers 4 256k;
    client_header_timeout 3m;
    client_max_body_size 300m;
    client_body_buffer_size 512k;
    send_timeout 60s;
    
    fastcgi_read_timeout 5000;
    fastcgi_connect_timeout 5000;
    fastcgi_send_timeout 5000;

    fastcgi_buffers 4 512k;
    fastcgi_buffer_size 256k;
    fastcgi_busy_buffers_size 512k;
    fastcgi_temp_file_write_size 512k;

    proxy_connect_timeout 600;
    proxy_read_timeout 600;
    proxy_send_timeout 600;
    proxy_buffer_size 256k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
    proxy_temp_file_write_size 256k;
    proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
    proxy_max_temp_file_size 128m;

    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4  16k;
    gzip_http_version 1.1;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml;
    gzip_vary  on;
upstream portal-html {
    server ip;
}

server {
        listen 80;
        server_name servername;
location = /limited.html {
    root   /usr/share/nginx/html/portal;
}
location = /m/limited.html {
    root   /usr/share/nginx/html/;
}

location ~* ^(|/|/[^/]+\.html)$ {
    error_page 403 /limited.html;    
    if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
        rewrite ^(.*)$ https://$host/m$1 redirect;
        break;
    }
    proxy_pass  http://portal-html;
}
location /m {
    error_page 403 /m/limited.html;
    proxy_pass  http://portal-html;
}
}
}