Issue type : Unable to use nginx container as load balancer.
OS Version/build : Windows 10 Enterprise Operating System
App version : Docker Version
Client : 17.06.2-ce
Server: 17.06.2-ce
Steps to reproduce
1.Pulled nginx image
2. Created 2 containers using nginx image as web server
docker run --name nx1 -p 8080:80 -v C:\Users\rama\Docker\NGINX\HTML1:/usr/share/nginx/html nginx
docker run --name nx2 -p 8082:80 -v C:\Users\rama\Docker\NGINX\HTML2:/usr/share/nginx/html nginx
3. Verified both are working as expected by accessing localhost:8080 and localhost:8082 from browser
4. Created nginx.conf under C:\Users\rama\Docker\NGINX\HTML3\ to make the 3rd container as load balancer
Content of nginx.conf are given below
#user nginx;
#worker_processes 1;
#error_log /var/log/nginx/error.log warn;
#pid /var/run/nginx.pid;
http {
upstream myapp1 {
server 127.0.0.1:8080;
server 127.0.0.1:8082;
}
server {
listen 8083;
location / {
proxy_pass http://myapp1;
}
}
}
events {
worker_connections 1024;
}
#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;
include /etc/nginx/conf.d/*.conf;
#}
- Executed following command to make the 3rd nginx container as load balancer however it is not working
docker run --name nx3 -p 8083:80 -v C:\Users\rama\Docker\NGINX\HTML3\nginx.conf:/etc/nginx/nginx.conf nginx
When I “localhost:8083” URL from Google Chrome or fire fox following URL and I am getting
"This page isn’t working
127.0.0.1 didn’t send any data.
ERR_EMPTY_RESPONSE"
I am trying to run 3 containers of nginx. 2 containers as web server and 1 as load balancer. Can anybody tell me what configuration is wrong here?