user www www;
worker_processes 8;
error_log logs/error.log notice;
pid pid/nginx.pid;
events
{
use epoll;
worker_connections 65535;
}
http
{
proxy_temp_path /usr/local/nginx/cache/proxy_temp_dir;
proxy_cache_path /usr/local/nginx/cache/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
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;
server {
listen 80;
server_name tomcat.qubaoquan.com;
index index.jsp index.htm index.html;
root /usr/local/nginx/html;
log_not_found off;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/nginx/html;
}
upstream tomcat
{
server 192.168.10.26:8080 weight=1;
server 192.168.10.28:8080 weight=1;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
{
proxy_redirect off;
#proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $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;
proxy_headers_hash_max_size 1024;
proxy_headers_hash_bucket_size 128;
proxy_ignore_headers "Cache-Control" "Expires";
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 12h;
proxy_cache_valid 301 302 1m;
proxy_cache_valid any 1m;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
if ($request_uri ~ "^/test1")
{
proxy_pass http://tomcat;
}
if ($request_uri ~ "^/test2")
{
proxy_pass http://192.168.10.26:8080;
}
if ($request_uri ~ "^/ispace1")
{
proxy_pass http://192.168.10.29;
}
expires 1d;
}
#location ~ .*\.(jsp)?$
location /
{
proxy_redirect off;
#proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $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;
proxy_headers_hash_max_size 1024;
proxy_headers_hash_bucket_size 128;
proxy_ignore_headers "Cache-Control" "Expires";
if ($request_uri ~* "^/test1")
{
proxy_pass http://tomcat;
}
if ($request_uri ~ "^/test2")
{
proxy_pass http://192.168.10.26:8080;
}
if ($request_uri ~ "^/ispace1")
{
proxy_pass http://192.168.10.29;
}
}
}
server
{
listen 80;
server_name status.qubaoquan.com;
location /
{
stub_status on;
access_log off;
}
}
}
nginx代理,缓存,负载tomcat示例
原创
©著作权归作者所有:来自51CTO博客作者qubaoquan的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Nginx反向代理、缓存、负载均衡
nginx反向代理,缓存,负载均衡,自定义响应首部
nginx负载均衡 nginx反向代理 nginx缓存