0%

nginx配置静态网页

负载均衡

1
2
3
4
5
6
upstream bbs {
server music.istorm.cc:80 weight=1;
}
upstream blog {
server http://0.0.0.0:2020 weight=1;
}

静态服务器和动态服务器配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
server {
listen 80;
server_name music.istorm.cc;
location / {
#这个地方指定被访问的文件夹位置
root /var/www/static/music;
index index.html;
}
#location /二级域名/ {
# root /var/www/static/music;
# index index.html;
#}
}

server{
listen 80;
# 配置 www.istorm.cc
server_name www.istorm.cc;
access_log /var/log/nginx/www.log;
location / {
root /home/website_root;
# proxy_pass 为反向代理后的 网站
proxy_pass http://0.0.0.0:2020;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;

}
}