您的位置:首页 > 运维架构 > Tomcat

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

2016-01-06 00:00 609 查看
摘要: 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;
&nbs
3ff0
p; }
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: