Docker Community Forums

Share and learn in the Docker community.

Tomcat cluster with nginx

docker

(Mpickelo) #1

Im trying to create a 5 node tomcat cluster using nginx as load balancer

Theres something wrong with my congig, I think. I can get nginx online, but not a single tomcat node.

I get an error saying I cant bind with port 80 because its already in use, but nothing else is using it.

Any help is greatly appreciated. Im pretty new at this.

Here is a copy of my config:

worker_processes 1;

events { worker_connections 1024; }

http {

sendfile on;

upstream app-server  {
	server tcat2-srv1:8080;

	
	
	
}

server {
	
listen MYIP:80;


	
	
	location / { 
	
		proxy_pass         app_servers;
        proxy_redirect     off;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;


	}
	
}

}


(Siju Oommen George) #2

are you very sure nothing is using it?
Soon after you get this error run

$ sudo netstat -plnt

and please provide your output

–Siju


(Mpickelo) #3

Thanks for your reply!
After running that, here is my output:

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 162.243.207.235:3306 0.0.0.0:* LISTEN -
tcp 0 0 162.243.207.235:1099 0.0.0.0:* LISTEN -
tcp 0 0 162.243.207.235:1100 0.0.0.0:* LISTEN -
tcp 0 0 162.243.207.235:8180 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 162.243.207.235:40411 0.0.0.0:* LISTEN -
tcp 0 0 162.243.207.235:40412 0.0.0.0:* LISTEN -
tcp 0 0 162.243.207.235:10334 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN


(Siju Oommen George) #4

run this command first in a terminal

$ watch -n 1 " fuser 80/tcp >> port80.txt"

Now start your application till it show the “error saying I cant bind with port 80 because its already in use” error

Now look in file port80.txt and see if at any point any process has hijacked port 80.
If you get a number in the file look for the process with that number.

–Siju