# #############################################################################
#
#  1.
#     a)proxy_temp_path
#     b)proxy_cache_path
#     c)upstream backend_server 206.69
#
# #############################################################################

#user  nobody;
worker_processes  1;

#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

worker_rlimit_nofile 65535;

events {
    use epoll;
    worker_connections  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    ## Log Options
    log_format   main '[$time_local] $status $remote_addr "$request" "$request_body" "$http_referer" $body_bytes_sent $request_time $upstream_response_time';
    #log_format   main '[$time_local] $status $body_bytes_sent $remote_addr "$request" $body_bytes_sent "$http_referer" "$http_user_agent" ';
    access_log  logs/access.log  main;
    access_log on;

    ## Size Limits
    server_names_hash_bucket_size 128;
    client_header_buffer_size   32k;
    client_body_buffer_size     512k;
    client_max_body_size        30m;
    large_client_header_buffers 4 32k;

    ## Timeouts
    client_body_timeout         50;
    client_header_timeout       50;
    keepalive_timeout           65;
    send_timeout                50;

    ## General Options
    charset       utf-8;
    ignore_invalid_headers      on;
    keepalive_requests          100;
    limit_conn_zone            $binary_remote_addr zone=perip:5m;
    recursive_error_pages       on;
    sendfile                    on;
    server_name_in_redirect     on;
    server_tokens               off;

    ## TCP Options
    tcp_nopush     on;
    tcp_nodelay    on;

    ## Compression
    gzip                on;
    #gzip_static        on;
    gzip_min_length     1k;
    gzip_buffers        16 8k;
    gzip_http_version   1.1;
    gzip_comp_level     9;
    gzip_types          text/plain application/x-javascript text/css application/xml application/json;
    gzip_vary           on;

    ## Proxy Options
    proxy_connect_timeout       300;
    proxy_read_timeout          300;
    proxy_send_timeout          600;

    proxy_buffering             on;
    proxy_buffers              32 32k;
    proxy_buffer_size          64k;
    proxy_busy_buffers_size    128k;
    #proxy_temp_file_write_size 128k;
    #proxy_temp_path  temp/proxy_temp_dir;
    proxy_cache_path  temp/proxy_cache_dir  levels=1:2   keys_zone=cache_one:200m inactive=1d max_size=1g;

    proxy_set_header Host  $host;
    proxy_set_header X-Forwarded-For  $remote_addr;
    upstream backend_server {
        server   60.28.206.69:80 weight=1 max_fails=2 fail_timeout=80s;
        #server  60.28.206.74:80 weight=1 max_fails=2 fail_timeout=80s;
        #server   211.100.54.131:80 weight=1 max_fails=2 fail_timeout=80s;
        #server  60.28.201.229:80 weight=1 max_fails=1 fail_timeout=30s;
    }

    server {
        listen       80;
        server_name  www.huoyunren.com huoyunren.com www.dingweiying.com dingweiying.com;

        access_log  logs/www.log  main;
        #access_log  off;

        location = / {
           proxy_pass http://backend_server;
        }

        location / {
            index  index.php index.html;
            proxy_cache cache_one;
            proxy_cache_valid  200 304 12h;
            proxy_cache_key $host$uri$is_args$args;
            proxy_ignore_headers   Expires Cache-Control;
            proxy_next_upstream http_502 http_504 error timeout invalid_header;
            proxy_pass http://backend_server;
        }

        location /status {
            stub_status on;
            access_log off;
        }

        #.php.jsp.cgi
        location ~ .*\.(php|jsp|cgi|exe|xml)?$
        {
            proxy_pass http://backend_server;
        }
        location ~ .*\.(js|css|gif|jpg|jpeg|ico)?$
        {
            access_log off;
            proxy_cache cache_one;
            proxy_cache_valid  200 304 1d;
            proxy_cache_key $host$uri$is_args$args;
            proxy_ignore_headers   Expires Cache-Control;
            expires 30d;
            proxy_pass http://backend_server;
        }
        location /haproxy-status {
           # proxy_pass http://localhost:81/haproxy-status;
        }
    }
    server {
        listen  8088;

        charset   gbk;
	access_log off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.195.52:8088;
	   #proxy_pass http://121.22.4.68:8089;
        }
    }

    server {
        listen 80;
        server_name  www.chinawayltd.com;
	access_log off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://backend_server;
        }
    }

    upstream ips_server {
        server  60.28.206.69:80 weight=1 max_fails=1 fail_timeout=30s;
        server  60.28.206.74:80 weight=1 max_fails=1 fail_timeout=30s;
        #server  211.100.54.133:80 weight=1 max_fails=1 fail_timeout=30s;
        #erver  60.28.201.229:80 weight=1 max_fails=1 fail_timeout=30s;
    }
    # no cache for ips
    server {
        listen 80;
        server_name  ips.huoyunren.com;
	access_log  logs/ips.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
           proxy_connect_timeout       30s;
           proxy_read_timeout          30s;
           proxy_pass http://ips_server;
        }
        location ~ .*\.(js|css|gif|jpg|jpeg|ico)?$
        {
            access_log off;
            proxy_cache cache_one;
            proxy_cache_valid  200 304 1d;
            proxy_cache_key $host$uri$is_args$args;
            proxy_ignore_headers   Expires Cache-Control;
            expires 30d;
            proxy_pass http://ips_server;
        }
        location /http/ips_dispathDoc.php {
            proxy_pass http://120.136.168.180;
        }


        location /http/ips_cnexcarriage3rd.php {
            proxy_pass http://120.136.168.180;
        }
    }

    upstream ips2_server {
        #server  60.28.206.74:80 weight=1 max_fails=2 fail_timeout=60s;
        server  60.28.206.76:80 weight=1 max_fails=2 fail_timeout=60s;
#        server  211.100.54.133:80 weight=1 max_fails=2 fail_timeout=60s;
#        server  60.28.201.229:80 weight=1 max_fails=1 fail_timeout=30s;
    }
    server {
        listen 80;
        server_name  elt.huoyunren.com ips2.huoyunren.com mobile.huoyunren.com deppon.huoyunren.com deppon1.huoyunren.com tnt.huoyunren.com deepure.huoyunren.com jiaji.huoyunren.com ems.huoyunren.com sunjex.huoyunren.com yuanshun.huoyunren.com yhdt.huoyunren.com tf56.huoyunren.com itl.huoyunren.com cre.huoyunren.com g7.huoyunren.com DBSchenker.huoyunren.com zhongnan.huoyunren.com;
	access_log  logs/ips2.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
           proxy_connect_timeout       30s;
           proxy_read_timeout          30s;
           proxy_pass http://ips2_server;
        }

#        location ~ .*\.(js|css)?$ {
#            expires      1h;
#        }

        location ~ .*\.(js|css|gif|jpg|jpeg|ico)?$
        {
           access_log off;
           proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
           proxy_connect_timeout       30s;
           proxy_read_timeout          30s;
           proxy_pass http://ips2_server;
        }
    }


    server {
        listen 80;
        server_name  gpsadmin.huoyunren.com pms.huoyunren.com ips2test.huoyunren.com deppontest1.huoyunren.com deppontest2.huoyunren.com;
	access_log  logs/admin.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.76;
        }
        location ~ .*\.(css|gif|jpg|jpeg|ico)?$
        {
            access_log off;
            proxy_cache cache_one;
            proxy_cache_valid  200 304 1d;
            proxy_cache_key $host$uri$is_args$args;
            proxy_ignore_headers   Expires Cache-Control;
            expires 30d;
            proxy_pass http://60.28.206.76;
        }
    }

    server {
        listen 80;
        server_name  ips2demo.huoyunren.com;
        access_log  logs/admin.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.74;
        }
        location ~ .*\.(css|gif|jpg|jpeg|ico)?$
        {
            access_log off;
            proxy_cache cache_one;
            proxy_cache_valid  200 304 5m;
            proxy_cache_key $host$uri$is_args$args;
            proxy_ignore_headers   Expires Cache-Control;
            expires 30d;
            proxy_pass http://60.28.206.74;
        }
    }

    server {
        listen 80;
        server_name  jiekou.huoyunren.com;
	access_log  logs/jiekou.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.195.54;
        }
    }
    server {
        listen 80;
        server_name  jkb.huoyunren.com;
	access_log  logs/jkb.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.74;
        }
    }

    server {
        listen 80;
        server_name  gps.jiaji.com gpscnc.jiaji.com;
	access_log  off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://120.136.168.180;
        }
    }

    server {
        listen 80;
        server_name  cnex.huoyunren.com;
	#access_log  off;
	access_log  logs/cnex.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://61.152.207.205;
        }
    }

    server {
        listen 80;
        server_name  f1.huoyunren.com;
	access_log  off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.72;
        }
    }
    server {
        listen 80;
        server_name  g.huoyunren.com kxx.huoyunren.com telecom.huoyunren.com zpt.huoyunren.com mzpt.huoyunren.com;
	access_log  logs/g.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.74;
        }
    }
    server {
        listen 80;
        server_name  api.huoyunren.com;
	access_log  logs/api.log  main;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.75;
        }
    }

    server {
        listen 80;
        server_name  gpstest.huoyunren.com;
	access_log  off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.69;
        }
    }
    server {
        listen 80;
        server_name  d.huoyunren.com;
	access_log  off;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

        location / {
           proxy_pass http://60.28.206.74;
        }
    }

}

