使用NGINX 來進行反向代理
阿新 • • 發佈:2019-01-05
部分轉載其他頁面。
設定反向代理充當負載均衡。
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
upstream 1.2.3.4 {
server 10.0.0.111:80;
server 10.0.0.137:80;
}
include /etc/nginx/conf.d/*.conf;
}
upstream是定義在server{ }之外的,不能定義在server{ }內部。定義好upstream之後,用proxy_pass引用一下即可