在之前的一篇博客中我们实现了使用Docker的官方nginx镜像来实现负载均衡,使用起来并不是很方便,这里使用我自己的镜像:chenyufeng/nginx-centos来实现负载均衡。使用chenyufeng/nginx-centos镜像更符合在Linux上对nginx的配置,将会更加方便。
/usr/local/nginx/conf/nginx.conf配置如下:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_refere