Windows下Nginx+Tomcat整合的安装与配置

#user  nobody;
worker_processes  1;

#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;
}


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  65;

    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 3;
    gzip_types  text/plain application/x-javascript application/javascript text/css application/xml;
    gzip_vary on;  
    
    upstream  test.pinganziben.com   {  
        server   localhost:8080;   
    }
    
    ## 这里取得原始用户的IP地址
    map $http_x_forwarded_for  $clientRealIp {
        ""    $remote_addr;
        ~^(?P<firstAddr>[0-9\.]+),?.*$    $firstAddr;
    }

    ## 针对原始用户 IP 地址做限制
    #limit_conn_zone $clientRealIp zone=TotalConnLimitZone:20m ;
    #limit_conn  TotalConnLimitZone  50;
    #limit_conn_log_level notice;

    ## 针对原始用户 IP 地址做限制
    #limit_req_zone $clientRealIp zone=ConnLimitZone:20m  rate=10r/s;
    #limit_req zone=ConnLimitZone burst=10 nodelay;
    #limit_req_log_level notice;

    #tomcat代理
    server {
        listen       80;
        server_name localhost;  
        location / {  
            proxy_pass http://localhost:8080;  
        }
    }

    #设定访问静态文件直接读取不经过

    server {
        listen       3333;
        server_name  localhost;
        #limit_req zone=ConnLimitZone burst=1 nodelay;
        root   C:/antiques;
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|html)$ #
        {  
            expires      1d;  
        }
    }


}

你可能感兴趣的:(Windows下Nginx+Tomcat整合的安装与配置)