tomcat 2대로 만들기
- nginx & tomcat load balancing
docker nginx&tomcat load balancing
docker-compse.yaml
version: '3.1'
services:
tomcat1:
image: tomcat:8.0
restart: always
container_name: tomcat1
environment:
- HOME_PATH=/home
ports:
- 8080:8080
volumes :
- ./data/files:/home/files
networks:
- mynetwork
tomcat2:
image: tomcat:8.0
restart: always
container_name: tomcat2
environment:
- HOME_PATH=/home
ports:
- 8081:8080
volumes :
- ./data/files:/home/files
networks:
- mynetwork
nginx:
image: nginx:stable
restart: always
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
- .vol/nginx/nginx.conf:/etc/nginx/nginx.conf
networks:
- mynetwork
depends_on:
- tomcat1
networks:
mynetwork:
C:\Users\mjSeo\vol\nginx\nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
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;
server {
listen 80;
location / {
proxy_pass http://apiserver;
}
}
upstream apiserver {
server tomcat1:8080;
server tomcat2:8081;
}
}
docker-compose up