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