ITeye博客

nginx 简单配置tomcat

rfv1116 · 2011-09-14 13:30 · 服务器 · 开源软件 · Markdown

#user nobody; worker_processes 2;

#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; error_log /usr/local/nginx/logs/nginx_error.log crit; pid /usr/local/nginx/nginx.pid;

events { worker_connections 65535; 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;

#General Options
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_body_buffer_size    8m; #256k 
server_tokens off;
ignore_invalid_headers   on;
recursive_error_pages    on;
server_name_in_redirect off;  
sendfile                 on;

#timeouts
keepalive_timeout      60;
#client_body_timeout   3m;
#client_header_timeout 3m;
#send_timeout          3m;

#TCP Options 
tcp_nopush  on;
tcp_nodelay on;


#size limits
client_max_body_size       50m;

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; 

upstream servers {
   
     server 192.168.1.108:8080;
     #server x.x.x.x:8080 max_fails=0 weight=1; #8080为tomcat端口
 }



server {
    listen       80;
    server_name  test.zl.com;

    #charset koi8-r;
 charset utf-8;
access_log  logs/access.log  main;
    

    location / {
        index  index.html index.htm;
    root  /prod/nginxtest;  #设定访问路径
   
    }
    
location ~* \.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|txt|wma)$
    {
      root /prod/nginxtest;
      expires 24h;
    }

location ~*\.(jsp|do|action)$
    {
      index index.jsp;
      proxy_pass http://localhost:8080;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header REMOTE-HOST $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

   

location /status {
      stub_status   on;
      access_log    on;
      allow    all;
    }


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


# 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       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  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers   on;

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

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。