Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29308293
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: 系统运维

2010-05-17 13:45:56

nginx+resin配置成功版

测试站点:简单的一个servelts + jsp + html + css + js + jpg等图片

Resin配置文件为:

D:\bjproj         存放的是站点的根目录位置

我的nginx的配置文件如下:


 


#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 {
    use select;
    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"';

    log_format download '$remote_addr - $remote_user [$time_local]'
            '"$request" $status $bytes_sent'
            '"$http_referer" "$http_user_agent"'
            '"$http_range" "$sent_http_content_range"';

    access_log logs/access.log main;

    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;

    #set client_header
    client_header_buffer_size 1k;
    large_client_header_buffers 4 4k;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    #keepalive_timeout 0;
    keepalive_timeout 65;

    #gzip on;
    gzip on;
    gzip_min_length 1100;
    gzip_buffers 4 8k;
    gzip_types text/plain application/x-javascript text/css application/xml;
    output_buffers 1 32k;
    postpone_output 1460;

    server {
        listen 80;
        server_name 192.168.100.40;

        charset utf-8;

        access_log logs/host.access.log main;
    
    location / {
     root D:\bjproj;
     index index.jsp;
     proxy_pass http://localhost:8080;
     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_buffers 32 4k;
    }

    location ~* \.(jsp|do|shtml)$ {
     root D:\bjproj;
     index index.jsp;
     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_buffers 32 4k;
     proxy_pass http://localhost:8080;
     proxy_set_header X-Real-IP $remote_addr;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
     root D:\bjproj;
     expires 1d;
    }

    location ~ .*\.(js|css)?$ {
     root D:\bjproj;
     expires 1h;
    }

#    location ~ ^/(servlet|aaaa|bbbbbb)/ {
#     proxy_pass http://localhost:8080;
#     proxy_set_header X-Real-IP $remote_addr;
#    }

    
#     location / {
#     root D:\bj;
#     index login.jsp;
#     proxy_pass http://localhost:8080;
#     proxy_set_header X-Real-IP $remote_addr;
#     }


#     location ~* \.(jsp|do|shtml)$ {
#     root D:\bjproj;
#     index login.jsp;
#     proxy_pass http://localhost:8080;
#     proxy_set_header X-Real-IP $remote_addr;
#     }

#     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
#     root D:/bjproj;
#     expires 1d;
#     }

#     location ~ .*\.(js|css)?$ {
#     root D:/bjproj;
#     expires 1h;
#     }





    
    location /(WEB-INF)/ {
        deny all;
    }

        

        #error_page 404 /404.html;
    #error_page 404 http:// ;

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


    # 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 E:\MyDjango\MyWork\servermonitor;
    # index index.html index.htm;
    # }
    #}


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

    # ssl on;
    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.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;
    # }
    #}

}


以上配置就可以实现nginx在前端做代理转发处理了!
阅读(1006) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~