访问静态资源:只配置一个server结点
server {
listen 80;server_name www.test1.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html-test1;
index index.html index.htm;
}
}
负载均衡
upstream sina{
server 192.168.93.134:8080;
server 192.168.93.134:8082 weight=2;
}
server {
listen 80;
server_name www.sina.com.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://sina;
index index.html index.htm;
}
}
动态代理(三步)
3. upstream sohu{
server 192.168.93.134:8081;
}
server {
listen 80;
1. server_name www.sohu.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
2. proxy_pass http://sohu;
index index.html index.htm;
}
}
记得重新加载nginx: ./nginx -s reload