这里只写一下主要配置,至于其他的开启日志,设置权重之类的有兴趣的话可以自行脑补。
以下配置,监听本机的80端口,为www.baidu.com这个域名提供服务。
效果:来自www.baidu.com的请求,平均地转发到 192.16.0.1:80, 127.0.0.1:8080 两个服务上。(nginx.conf)
另外:淘宝tengine的配置和这个基本一样
upstream main {
server 192.16.0.1:80;
//此处用于配置tomcat的路径,包括端口,此处也可以进行权重配置
server 127.0.0.1:8080;
}
server {
listen 80; //此处为监听端口,也就是访问时候URL的端口号
server_name www.baidu.com;
server_tokens off;
root /dev/null;
# Increase this if you want to upload larger attachments
client_max_body_size 20m;
# individual nginx logs for this vhost
access_log /var/log/nginx/store_access.log;
error_log /var/log/nginx/store_error.log;
location / {
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host teststore.boldseas.com;
#
for proxy to IIS
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://main;
//此处main和上边upstream main { ....... }中main的名字一样 ,需要注意
proxy_redirect off;
}
}
}
1086

被折叠的 条评论
为什么被折叠?



