`

nginx配置

 
阅读更多
#user  nobody;
worker_processes  8;

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

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
    use epoll;
}


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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush     on;


    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types text/plain application/x-javascript text/css application/xml;
    gzip_vary on;
    #rewrite http://91.myhttp.com/(.*) http://www.myhttp.com/$1 redirect;

     #缓存配置

  server_names_hash_bucket_size 128; 
  client_header_buffer_size 32k; 
  large_client_header_buffers 4 32k; 
  client_max_body_size 500m;
  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;
  #注:proxy_temp_path和proxy_cache_path指定的路径必须在同一分区
  proxy_temp_path   /opt/App/nginx_tmp;
  #设置Web缓存区名称为cache_one,内存缓存空间大小为200MB,1天没有被访问的内容自动清除,硬盘缓存空间大小为30GB。
  proxy_cache_path  /opt/App/nginx_cache  levels=1:2   keys_zone=cache_one:200m inactive=1d max_size=30g;



    #
    upstream tomcat8 {
        server 192.168.102.102:8080 weight=5;
    }
    upstream tomcat6 {
        ip_hash;
    	server 192.168.102.100:8080  max_fails=1 fail_timeout=5s;
        server 192.168.102.109:8082  max_fails=1 fail_timeout=5s;
    }
    upstream tomcat16 {
    	server 192.168.102.100:8080  max_fails=1 fail_timeout=5s;
        server 192.168.102.109:8082  max_fails=1 fail_timeout=5s;
    }
    upstream tomcatForJrtLot {
	server 192.168.102.100:8080  max_fails=1 fail_timeout=5s;
    }
    upstream tomcat9{
       server 192.168.102.109:8082 ;
    }
    upstream apptest{
      server 192.168.102.102:8090;
    }
    upstream tomcat10{
       server 192.168.102.102:8088;
    }
    upstream tomcat1008888{
       server 192.168.102.100:8888;
    }

    server {
        listen       8080;
        server_name www.myhttp.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        #rewrite ^/ecai http://www.ecai8.cn/ redirect;
#       rewrite http://91.myhttp.com/(.*) http://www.myhttp.com/$1 redirect;
      #  rewrite ^/upload http://wap.myhttp.com/ redirect;
        rewrite ^/myhttp http://www.myhttp.com/ redirect;
        location / {
	    index  index.html index.htm;
            root html;
            proxy_redirect          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;
            proxy_pass              http://192.168.102.108/;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;            
 #          rewrite ^/(.*) http://www.myhttp.com/myhttp/$1 permanent;
        }
        location /s/ {
           alias /usr/local/nginx/s/;
           
       }
       
        location ~ .*\.(gif|jpg|png|htm|html|css|js|flv|ico|swf)(.*) {
              proxy_pass http://appserver;
              proxy_redirect off;
              proxy_set_header Host $host;
              proxy_cache cache_one;
              proxy_cache_valid 200 302 1h;
              proxy_cache_valid 301 1d;
              proxy_cache_valid any 1m;
              expires 30d;
        }



      
       location /ChargeCenter {
            index  index.jsp;
            proxy_pass      http://tomcat10/ChargeCenter;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }

       location /app {
            index  index.jsp index.html;
            proxy_pass      http://apptest/app;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }
   
        location /mgr {
            index  index.jsp;
            proxy_pass      http://tomcat9/mgr;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }
	location /bqs {
            index  index.jsp;
            proxy_pass      http://tomcat1008888/bqs;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }
       location /jrtSubChannel {
            index  index.jsp;
            proxy_pass      http://tomcat16/jrtSubChannel;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }

       location /lotserver {
            index  index.jsp;
            proxy_pass      http://tomcat10/lotserver;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
         }
       
        location /bossclient {
            index  index.jsp;
            proxy_pass      http://tomcat10/bossclient;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
         }


        location /vipportal {
            proxy_pass      http://tomcat9/vipportal;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }

        location /ecai {
            index  index.jsp;
            proxy_pass      http://tomcat6/ecai;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }
 location /qudao {
            index  index.jsp;
            proxy_pass      http://tomcat8/qudao;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;

         }

       location /ussd {
            index  index.jsp;
            proxy_pass      http://tomcat8/ussd;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
   # location /upload {
   #         index  index.jsp;
   #         proxy_pass      http://tomcat8/upload;
   #         proxy_redirect          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;
   #         client_max_body_size    10m;
   #         client_body_buffer_size 128k;
   #         proxy_connect_timeout   90;
   #         proxy_send_timeout      90;
   #         proxy_read_timeout      90;
   #         proxy_buffer_size       4k;
   #         proxy_buffers           4 32k;
   #         proxy_busy_buffers_size 64k;
   #         proxy_temp_file_write_size 64k;
   #     }

  location /yizhifu {
            index  index.jsp;
            proxy_pass      http://tomcat8/yizhifu;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

 location /webimages/ {
            proxy_pass      http://tomcat8/webimages/;
            charset utf-8;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
  location /tongji {
            index  index.jsp;
            proxy_pass      http://tomcat6/tongji;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

        location /jrtNews {
            index  index.jsp;
            proxy_pass      http://tomcat6/jrtNews;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
 location /jrtRyc2 {
            index  index.jsp;
            proxy_pass      http://tomcat8/jrtRyc2;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

location /jrtGift{
            index  index.jsp;
            proxy_pass      http://tomcat6/jrtGift;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

location /g3cai {
            index  index.jsp;
            proxy_pass      http://tomcat6/g3cai;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }





        location /jrtLot {
            index  index.jsp;
            proxy_pass      http://tomcat6/jrtLot;
            proxy_redirect          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;
	    client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
	location /myhttp {
            index  index.html;
            proxy_pass      http://tomcat8/myhttp;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
    location /wirelessSupport {
            index  login.jsp;
            proxy_pass      http://tomcat8/wirelessSupport;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
         location /jrtMgr {
            index  index.html;
            proxy_pass      http://tomcat8/jrtMgr;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
location /jrtMgr2 {
            index  index.html;
            proxy_pass      http://tomcat6/jrtMgr2;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

 location /jrtLotUSSD {
            index    webindex.jsp   ;
            proxy_pass      http://tomcat6/jrtLotUSSD;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
 location /UMLot {
            index    webindex.jsp   ;
            proxy_pass      http://tomcat6/UMLot;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

	location /qiye {
            index    webindex.jsp   ;
            proxy_pass      http://tomcat6/qiye;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }





    server {
        listen       8080;
        server_name www.g3cai.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
           index  index.html index.htm;
            root html;
          rewrite ^/(.*) http://www.g3cai.com/g3cai/$1 permanent;
        }

 location /webimages/ {
            proxy_pass      http://tomcat6/webimages/;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
  location /tongji {
            index  index.jsp;
            proxy_pass      http://tomcat6/tongji;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

        location /myhttp{
            index  index.jsp;
            proxy_pass      http://tomcat8/myhttp;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
location /jrtGift{
            index  index.jsp;
            proxy_pass      http://tomcat6/jrtGift;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

location /g3cai {
            index  index.jsp;
            proxy_pass      http://tomcat8/g3cai;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
        location /jrtLot {
            index  index.jsp;
            proxy_pass      http://tomcatForJrtLot/jrtLot;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

 server {
        listen       8080;
        server_name nm.myhttp.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
           index  index.html index.htm;
            root html;
          rewrite ^/(.*) http://nm.myhttp.com/ussd$1 permanent;
        }
         location /ussd {
            index  index.html;
            proxy_pass      http://tomcat8/ussd;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

}

server {
        listen       8080;
        server_name www.51500.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        rewrite ^/myhttp http://www.myhttp.com/;
        location / {
           index  index.html index.htm;
            root html;
            rewrite ^/(.*) http://www.51500.cn/myhttp$1 permanent;
        }
        location /webimages/ {
            proxy_pass      http://tomcat8/webimages/;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

         location /myhttp {
            index  index.html;
            proxy_pass      http://tomcat8/myhttp;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

}
        server {
             listen       8080;
        server_name     www.ecai8.cn;

        #charset koi8-r;

      # rewrite ^/ecai http://www.ecai8.cn/ redirect;
        #access_log  logs/host.access.log  main
        location / {
           index  index.html index.htm;
           root html;
           rewrite ^/(.*) http://www.ecai8.cn/ecai/$1 permanent;
        }

         location /ecai { 
            index index.jsp;
            proxy_pass      http://tomcat6/ecai;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
      }



    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    server {
     	listen       8443;
	server_name  localhost;

    	ssl  on;
  	ssl_certificate      /usr/local/nginx/myhttp.pem;
    	ssl_certificate_key  /usr/local/nginx/myhttp.key;

    	ssl_session_timeout  5m;

   	ssl_protocols  SSLv2 SSLv3 TLSv1;
     	ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
     	ssl_prefer_server_ciphers   on;

        location / {
           # root   html;
           # index  index.html index.htm;
	    rewrite ^/(.*) https://www.myhttp.com/myhttp/$1 permanent;
       	}
	 location /jrtLot {
            index  index.jsp;
            proxy_pass      http://tomcatForJrtLot/jrtLot;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }

	location /jrtMgr {
            index  index.html;
            proxy_pass      http://tomcat6/jrtMgr;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
	location /myhttp {
            index    webindex.jsp   ;
            proxy_pass      http://tomcat8/myhttp;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
     }
 server {
        listen       8080;
        server_name  tianya.myhttp.cn;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;
           location / {
             index index.html index.htm;
             root html;
             rewrite ^/(.*) http://tianya.myhttp.cn/w/$1 permanent;
        }

   location /w {
            index   wapindex.jsp;
            proxy_pass      http://tomcat8/w;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
             proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }    
}
   


 server {

        listen       8080;
        server_name  hlxk.myhttp.com;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;
           location / {
             index index.html index.htm;
             root html;
             rewrite ^/(.*) http://hlxk.myhttp.com/w/$1 permanent;
        }

   location /w {
            index   wapindex.jsp;
            proxy_pass      http://tomcat8/w;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
             proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
}



 server {
        listen       8080;
        server_name  wxcs.myhttp.com;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;
           location / {
             index index.html index.htm;
             root html;
             rewrite ^/(.*) http://wxcs.myhttp.com/w/$1 permanent;
        }

   location /w {
            index   wapindex.jsp;
            proxy_pass      http://tomcat8/w;
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
             proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
}

    server {
        listen       8080;
        server_name  myhttp.com *.myhttp.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        rewrite ^/(.*) http://www.myhttp.com/$1 redirect;

        location / {
            index  index.html index.htm;
            root html;
            proxy_redirect          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;
            proxy_pass              http://192.168.102.108/;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
   }

    server {
        listen       8080;
        server_name  myhttp.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        rewrite ^/ http://www.myhttp.com/ redirect;

        location / {
            index  index.html index.htm;
            root html;
            proxy_redirect          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;
            proxy_pass              http://192.168.102.108/;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
   }
      server {
        listen       8080;
        server_name  www.myhttp.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        rewrite ^/ http://www.myhttp.com/ redirect;

        location / {
            index  index.html index.htm;
            root html;
            proxy_redirect          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;
            proxy_pass              http://192.168.102.108/;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
   }
}


注意:如果外网端口不是80端口和nginx 的80端口映射,比如,外网的211.123.45.56 的8090与某台机器的nginx的80端口做映射,配置如下:
location /jrtLot {
            index  index.jsp;
            proxy_pass      http://tomcatForJrtLot/jrtLot/;#区别
            proxy_redirect          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;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout   90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size       4k;
            proxy_buffers           4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }



如果不加后面的/斜线,nginx日志会报302错误,并且重定向到211.123.45.56 的80端口
1、http段设置。
proxy_temp_path /home/temp_dir;设置临时目录
proxy_cache_path /home/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;设置缓存目录为二级目录,共享内存区大小,非活动时间,最大容量,注意临时目录要跟缓存目录在同一个分区。
2、server段设置
请求静态文件设置。
proxy_cache cache_one;设置缓存共享内存区块,也就是keys_zone名称。
proxy_cache_valid 200 302 1h;设置http状态码为200,302缓存时间为1小时。
expires 30d;设置失期时间,为30天
请求动态文件设置。
proxy_pass http://appserver;不进行缓存,直接转到后端服务器。
测试:当客户端发起http请求时在服务器上会产一个缓存文件如


/home/cache/0/b9/8bd841b1c44ee5b91457eb561e44eb90 


缓存清除
 location ~ /purge(/.*)
    {
     #设置只允许指定的IP或IP段才可以清除URL缓存。
     allow            127.0.0.1;
     allow            192.168.0.0/16;
     deny            all;
     proxy_cache_purge    cache_one   $host$1$is_args$args;
    }
安装Purge模块,Purge模块被用来清除缓存的。
分享到:
评论

相关推荐

    Nginx 配置文件 nginx.conf 详解

    Nginx 配置文件 nginx.conf 详解 Nginx 配置文件 nginx.conf 是 Nginx 服务器的核心配置文件,它控制着 Nginx 服务器的行为和性能。在这个配置文件中,我们可以设置服务器的用户和组、工作进程数、错误日志、进程...

    nginx配置多个静态资源.docx

    nginx配置多个静态资源 本文将详细介绍nginx配置多个静态资源的知识点,从基本概念到配置实践,涵盖了nginx配置文件的各个组件和指令。 nginx配置文件结构 nginx配置文件主要由以下几个部分组成: * main块:...

    Nginx配置文件(nginx.conf)配置详解[定义].pdf

    Nginx配置文件(nginx.conf)配置详解 Nginx配置文件(nginx.conf)是Nginx服务器的核心配置文件,用于定义Nginx服务器的行为和配置。下面是Nginx配置文件的详细配置解释: 用户和组 Nginx配置文件中指定了用户和组,...

    notepad++编辑nginx配置文件支持高亮

    在标题“notepad++编辑nginx配置文件支持高亮”中,我们关注的是如何在Notepad++中实现对Nginx配置文件的语法高亮显示,这将极大提升开发者的阅读和编写效率。 Nginx是一款高性能的HTTP和反向代理服务器,其配置...

    windows下 php+nginx配置详解

    设置监听地址和端口,与Nginx配置中的`fastcgi_pass`对应: ```ini listen = 127.0.0.1:9000 ``` 启动Nginx和PHP-FPM服务。如果一切配置无误,现在你应该可以通过浏览器访问`http://localhost/`并看到Nginz的欢迎...

    nginx配置 +负载均衡+https协议

    - 对于负载均衡,可以通过在Nginx配置文件中定义多个后端服务器,并使用`proxy_pass`指令来实现。 ```nginx upstream backend { server backend1.example.com; server backend2.example.com; } server { ...

    项目打包运行dist以及nginx配置

    在IT行业中,项目打包运行和Nginx配置是两个关键环节,它们对于应用程序的部署和发布至关重要。这里我们将深入探讨这两个主题。 首先,项目打包运行通常指的是将开发完成的前端或后端应用转换为可部署的形式。对于...

    Windows平台,Nginx配置文件修改自动加载重启

    本教程将介绍一种方法,使得在Windows环境下,Nginx配置文件修改后能够自动加载并重启,以实现配置的即时生效。 首先,`nginx.conf`是Nginx的主要配置文件,它包含了服务器的各项设置,如监听端口、服务器块、反向...

    Nginx配置SSL自签名证书的方法

    3. **编辑Nginx配置文件**:找到Nginx的配置文件,通常是`/etc/nginx/nginx.conf`或`/usr/local/nginx/conf/nginx.conf`。添加一个新的`server`块,配置如下: ```nginx server { listen 80; listen 443 ssl; # ...

    微信小程序https服务nginx配置示例.pdf

    6. 反向代理配置:在nginx配置中,proxy_pass指令用于指定后端的服务器地址,这里指向了本地的8080端口。同时,还通过proxy_set_header指令设置了传递给后端服务器的HTTP头信息,如X-Forwarded-For(客户端IP地址)...

    Vue项目部署Nginx配置文件 SSL

    在部署 Vue 项目时,Nginx 配置文件 `nginx.conf` 的关键设置如下: 1. **基本配置**: - `server` 块:定义一个监听特定端口(通常是80)的服务器实例。 ```nginx server { listen 80; server_name your...

    windows下nginx配置https以及同一个端口监听多个网站即监听多个虚拟主机

    在Windows环境下,配置Nginx以支持HTTPS及在同一端口监听多个网站,即配置多个虚拟主机,是一项常见的网络服务设置任务。...同时,根据实际需求,还可以对Nginx配置进行更复杂的优化,如负载均衡、缓存等。

    Nginx配置如何区分PC或手机访问不同域名

    在Nginx配置中,我们通常使用`if`语句和`rewrite`模块来根据不同的条件重写请求。例如,若想在移动端访问时重定向到另一个域名(如***),可以利用Nginx配置文件中的`if`语句,结合正则表达式匹配HTTP_USER_AGENT,...

    Nginx配置http转https以及https访问http静态资源.docx

    三、Nginx配置安全头 在上面的配置文件中,我们使用了add_header指令来添加Content-Security-Policy头,以便升级不安全的请求。这可以防止攻击者inject恶意脚本来攻击网站。 四、Nginx配置错误页面 在上面的配置...

    nginx配置.zip

    1. **Nginx配置基础** Nginx的配置文件通常位于`/etc/nginx/`目录下,其中`nginx.conf`是主配置文件,它包含了整个Nginx服务器的基本设置。`conf.d`目录则用于存放多个独立的配置片段,这种方式使得配置管理更加...

    squid和nginx配置正向代理访问API接口.rar

    总结一下,"squid和nginx配置正向代理访问API接口"涉及的关键知识点包括正向代理的概念、Squid和Nginx的代理功能、配置这两者的步骤、以及安全性控制和优化策略。正确配置和使用这两个工具可以帮助企业构建高效、...

    Nginx配置文件——一级域名、二级域名

    本文将深入探讨如何通过Nginx配置文件来设置一级域名和二级域名,以及如何利用Nginx的反向代理功能。 首先,了解一级域名和二级域名的概念至关重要。一级域名是互联网上顶级的域名,如.com、.org、.net等。二级域名...

Global site tag (gtag.js) - Google Analytics