(작성중...)
$ docker network create mynetwork
$ docker network ls // 모든 network 리스트 확인
$ docker inspect mynetwork // 위에서 만든 mynetwork의 스펙을 자세하게 보기
$ docker run -itd --name sec_project <이미지이름>
$ docker network connect <네트워크이름> <존재하는 프로젝트이름>
$ docker network connect mynetwork project
$ docker network disconnect bridge project
$ docker run -itd --name sec_project --network mynetwork <이미지이름>
$ docker exec project ping sec_project
PING two (172.19.0.3): 56 data bytes
64 bytes from 172.19.0.3: seq=0 ttl=64 time=0.119 ms
64 bytes from 172.19.0.3: seq=1 ttl=64 time=0.105 ms
64 bytes from 172.19.0.3: seq=2 ttl=64 time=0.116 ms
64 bytes from 172.19.0.3: seq=3 ttl=64 time=0.883 ms
64 bytes from 172.19.0.3: seq=4 ttl=64 time=0.127 ms
// 설치 방법
$ apt-get update
$ apt-get install inetutils-ping
$ docker run -d --network mynetwork --name webserver -p 80:80 -p 443:443 -p 4000:4000 -p 8000:8000 nginx:latest
80과 443만 필요하지만 테스트용으로 만듬.
4000번 포트에 테스트
upstream react1 {
server react-app:3000;
}
server {
listen 4000;
listen [::]:4000;
server_name localhost;
location / {
proxy_pass http://react1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
잘 됐다면...
// default.conf
server {
listen 80;
listen [::]:80;
return 308 https://$host$request_uri;
}
// ssl.conf
upstream react3 {
server react-app:3000;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name nohsangwoossltest.com;
# ssl on
ssl_certificate /root/ssl/nginx-ssl.crt;
ssl_certificate_key /root/ssl/nginx-ssl.key;
location / {
proxy_pass http://react3;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}