1、找到nginx的配置文件
/usr/local/nginx/conf/nginx.conf
2、访问静态资源最简单的配置(访问路径:http://localhost:81)
# 静态http服务器
server {
# 监听80端口
listen 81;
# 域名 这里是本地访问
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# 需要映射的地址(这里以/开头)
location / {
# 静态资源的根目录
root html81;
# index页面
index index.html index.htm;
}
}
用图直观的说明:
4、作为反向代理服务器的配置
upstream search {
server 10.9.96.75:8080;
}
server {
# 监听80端口
listen 80;
# 域名
server_name www.taotao.search.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# 代理的地址
proxy_pass http://search;
index index.html index.htm;
}
}
5、作为负载均衡服务器的配置 (只需要设置weight值来)
upstream item {
server 10.9.96.75:8081 weight=1;
server 10.9.96.75:8082 weight=3;
}