Nginx-动静分离-图片和程序调用不同的服务器

2019年6月28日

user nginx;
worker_processes  1;
error_log /usr/local/nginx/logs/error.log crit;
pid /usr/local/nginx/nginx.pid;

events {
        use epoll;
        worker_connections  51200;
}

http {
        include mime.types;
        include proxy.conf;
        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 30m;
        sendfile on;
        tcp_nopush on;
        keepalive_timeout 60;

        gzip on;
        gzip_min_length  1k;
        #gzip_buffers     4 1
        gzip_http_version 1.0;
        gzip_comp_level 2;
        gzip_types text/plain application/x-javascript text/css application/xml;
        gzip_vary on;
        access_log  /usr/local/nginx/logs/access.log;
        #proxy_temp_file_write_size 128k;
        #proxy_temp_path /var/log/nginx/proxy_temp/proxy_temp_dir;
        #proxy_cache_path /var/log/nginx/proxy_temp/cache levels=1:2 keys_zone=cache:10m max_size=100m;
        #proxy_cache_key "$scheme://$host$uri";
        limit_req_zone  $binary_remote_addr  zone=one:10m   rate=1r/s;

        upstream backend {

                server 83.222.126.3:8080;
                #server 199.15.116.151:8080 weight=1;
        }

        upstream backend-img {

                server 199.15.116.151:8080;
        }

        server {
                listen 80;
                location / {
                        proxy_pass http://backend;
                        #proxy_next_upstream http_502 http_504 error timeout invalid_header;
                        #proxy_cache cache;
                        #proxy_cache_valid 200 304 1h;
                        #proxy_cache_key $host$uri$is_args$args;
                        #proxy_set_header Host $host;
                        #proxy_set_header X-Forwarded-For $remote_addr;
                        #expires 1h;
                        #IF 504
                        fastcgi_connect_timeout 500s;
                        fastcgi_send_timeout 500s;
                        fastcgi_read_timeout 1000s;
                        fastcgi_buffer_size 128k;
                        fastcgi_buffers 8 128k;#8 128
                        fastcgi_busy_buffers_size 256k;
                        fastcgi_temp_file_write_size 256k;
                        fastcgi_intercept_errors on;
                        limit_req   zone=one  burst=5  nodelay;
                }
                location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$  {
                       #expires      1h;
                        proxy_pass http://backend-img;
                }
                #location ~ .*.(js|css)?$  {
                #        expires      2m;
                #}
                #location ~ .*.(php|php5)?$ {
                #       limit_req   zone=one  burst=5 nodelay;
                #       fastcgi_pass unix:/tmp/php-cgi.sock;
                #       fastcgi_index index.php;
                #       include fastcgi.conf;
                #}

        }
}
 

没有评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注