nginx memo

nginx 反向代理

配置 nginx 作为反向代理实现负载均衡

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
33
34
upstream server1 {
# change this configure to conrresponding ports
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
server 127.0.0.1:8004;
}
server {
listen 8000;
root /path/to/server1; # change this config to the corresponding path
location / {
proxy_pass http://server1;
proxy_connect_timeout 60s;
}
}
# -------------------------------------------------------------------------
upstream server2 {
# change this configure to conrresponding ports
server 127.0.0.1:9001;
server 127.0.0.1:9002;
server 127.0.0.1:9003;
server 127.0.0.1:9004;
}
server {
listen 9000;
root /path/to/server2; # change this config to the corresponding path
location / {
proxy_pass http://server2;
proxy_connect_timeout 60s;
}
}

NGINX 文件服务器

1
2
3
4
5
6
7
8
9
10
11
server {
listen 8001;
server_name 10.83.152.74; # 自己PC的ip或者服务器的域名
charset utf-8; # 避免中文乱码
root /home/luban/workspace/gluon-park/1211/test_result; # 存放文件的目录
location / {
autoindex on; # 索引
autoindex_exact_size on; # 显示文件大小
autoindex_localtime on; # 显示文件时间
}
}