注意:
在设置 Nginx 代理之前要先安装 Nginx
正文:
内容一:设置 Nginx HTTP 代理
# vi /usr/local/nginx/conf/nginx.conf
将部分内容修改如下:
......
http {
.....
upstream webserver {
server 192.168.1.100:80;
server 192.168.1.200:80;
}
.....
server {
listen 80;
server_name www.eternalcenter.com;
location / {
proxy_pass http://webserver;
}
......
}
......
}
或者:
......
http {
.....
upstream webserver {
Server 192.168.2.100 weight=1 max_fails=1 fail_timeout=30;
Server 192.168.2.200 weight=2 max_fails=2 fail_timeout=30;
Server 192.168.2.101 down;
}
.....
server {
listen 80;
server_name www.eternalcenter.com;
location / {
proxy_pass http://webserver;
}
......
}
......
}
内容二:设置 Nginx SSH 代理
将部分内容修改如下:
stream {
upstream backend {
server 192.168.1.100:22;
server 192.168.1.200:22;
}
server{
listen 222;
proxy_connect_timeout 1s;
proxy_pass backend;
}
}
http{
......
}