Skip to content

Latest commit

ย 

History

History
218 lines (151 loc) ยท 5.67 KB

README.md

File metadata and controls

218 lines (151 loc) ยท 5.67 KB

์„œ๋น„์Šค ๋ฐฐํฌ ๋ฌธ์„œ

๋ฐฐํฌ ํ™˜๊ฒฝ

  • Ubuntu 20.04 LTS (GNU/Linux 5.4.0-1018-aws x86_64)
  • ํ™˜๊ฒฝ์— ๋”ฐ๋ผ vi, nano / ssh, bash ๊ฐ™์€ ๋ช…๋ น์–ด๊ฐ€ ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ์œผ๋‹ˆ ์ฃผ์˜
  • ์ฒ˜์Œ๋ถ€ํ„ฐ ๋๊นŒ์ง€ ์‰ฌ์ง€ ์•Š๊ณ  ์ง„ํ–‰ํ•˜๋Š” ๊ฒƒ์ด๋ฏ€๋กœ, ํ˜„์žฌ ๊ฒฝ๋กœ(์œ„์น˜)์— ์œ ์˜

Docker, docker-compose ์„ค์น˜

# ์‚ฌ์šฉ์ž root๋กœ ๋ณ€๊ฒฝ
sudo su

apt-get update

apt-get install \
	apt-transport-https \
	ca-certificates \
	curl \
	gnupg \
	lsb-release

-fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o
/usr/share/keyrings/docker-archive-keyring.gpg

echo \
	"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]
	https://download.docker.com/linux/ubuntu \
	$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get install docker-ce docker-ce-cli containerd.io

curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

OpenVidu Server ์„ค์น˜

  1. OpenVidu ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ
cd /opt # ์ดํ›„ ์ž‘์—…ํ•˜๋Š” ํŒŒ์ผ๋“ค๋„ opt์—์„œ ์ž‘์—…ํ•ฉ๋‹ˆ๋‹ค.

curl https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_latest.sh | sudo bash
  1. ํ™˜๊ฒฝ ์„ค์ • ํŒŒ์ผ ์ˆ˜์ •(.env)
cd /opt/openvidu

vi .env

# ์—๋””ํ„ฐ์—์„œ ์•„๋ž˜์˜ ๊ฐ’์„ ์ฐพ์•„์„œ ๋ณ€๊ฒฝ
DOMAIN_OR_PUBLIC_IP=<์„œ๋ฒ„ ์ฃผ์†Œ ๋˜๋Š” ๋„๋ฉ”์ธ>
OPENVIDU_SECRET=<์„œ๋ฒ„ ๋น„๋ฐ€๋ฒˆํ˜ธ>
CERTIFICATE_TYPE=letsencrypt # letsencrypt๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ SSL ์ธ์ฆ์„œ ๋ฐœ๊ธ‰
LETSENCRYPT_EMAIL=<์ด๋ฉ”์ผ> # letsencrypt์—์„œ ์‚ฌ์šฉํ•  ์ด๋ฉ”์ผ
HTTP_PORT=<ํฌํŠธ ๋ฒˆํ˜ธ>
HTTPS_PORT=<ํฌํŠธ ๋ฒˆํ˜ธ>
# ํฌํŠธ ๋ฒˆํ˜ธ ์ดํ›„์— ์ˆ˜์ • ์˜ˆ์ •
  1. OpenVidu ์„œ๋ฒ„ ์‹คํ–‰
./openvidu start
  1. ์„œ๋ฒ„ ์‹คํ–‰ ์—ฌ๋ถ€ ํ™•์ธ
docker ps

docker-openvidu

  1. ํฌํŠธ ๋ณ€๊ฒฝ์„ ์œ„ํ•œ ์„œ๋ฒ„ ์ข…๋ฃŒ
./openvidu stop
  1. ํ™˜๊ฒฝ ์„ค์ • ํŒŒ์ผ ํฌํŠธ๋ฒˆํ˜ธ ์ˆ˜์ •
HTTP_PORT=<๋ณ€๊ฒฝ ํฌํŠธ ๋ฒˆํ˜ธ>
HTTPS_PORT=<๋ณ€๊ฒฝ ํฌํŠธ ๋ฒˆํ˜ธ>
  1. OpenVidu ์„œ๋ฒ„ ์žฌ์‹œ์ž‘
./openvidu start

DB ์„ค์น˜

  1. Docker๋ฅผ ํ™œ์šฉํ•˜์—ฌ mariaDB 10.2 ์„ค์น˜
docker run --name mariadb -d -p <DB ํฌํŠธ ๋ฒˆํ˜ธ>:<DB ํฌํŠธ ๋ฒˆํ˜ธ> -e MYSQL_ROOT_PASSWORD=<root ๋น„๋ฐ€๋ฒˆํ˜ธ> mariadb:10.2
  1. MySQL Workbench ๋“ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ root๋กœ ์ ‘์† ํ›„ ์•„๋ž˜ ํŒŒ์ผ์˜ sql๋ฌธ ์‹คํ–‰

ํ”„๋กœ์ ํŠธ ์ปจํ…Œ์ด๋„ˆ ์ ์žฌ

  • ๋ฏธ๋ฆฌ ๋นŒ๋“œํ•ด๋‘” ํŒŒ์ผ์„ ์ด์šฉํ•˜์—ฌ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ฐฐํฌํ•ฉ๋‹ˆ๋‹ค.
  1. git ์„ค์น˜ ํ›„ ์ €์žฅ์†Œ clone
apt-get update

apt-get install git

cd /opt

git clone https://lab.ssafy.com/s06-webmobile1-sub2/S06P12A106.git # ์ดํ›„์— ๋‚˜์˜ค๋Š” git ์‚ฌ์šฉ์ž ์•„์ด๋”” ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ
  1. docker-compose ํ™œ์šฉํ•˜์—ฌ ํ”„๋กœ์ ํŠธ ์•ฑ ์ปจํ…Œ์ด๋„ˆ ์ ์žฌ
cd /opt/S06P12A106/backend/docker

docker-compose up --build -d springboot

SSL ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ ๋ฐ ํ”„๋กœ์ ํŠธ ๋ฐฐํฌ

  1. ์ธ์ฆ์„œ ๋ฐœ๊ธ‰์„ ์œ„ํ•œ ์ฝ”๋“œ ์ž‘์„ฑ ๋ฐ ์ˆ˜์ •
cd /opt/S06P12A106/backend/docker

vi /opt/nginx/conf.d/nginx.conf
# ์•„๋ž˜์˜ ์ฝ”๋“œ ์ž…๋ ฅ
server {
     listen <ํฌํŠธ ๋ฒˆํ˜ธ>;
     listen [::]:<ํฌํŠธ ๋ฒˆํ˜ธ>;

     server_name <๋„๋ฉ”์ธ ip ๋˜๋Š” ์ด๋ฆ„> # <>๊ด„ํ˜ธ ์ง€์šฐ๊ณ  ์ž…๋ ฅํ•  ๊ฒƒ

     location /.well-known/acme-challenge/ {
             allow all;
             root /var/www/certbot;
     }
}

vi /opt/S06P12A106/backend/docker/init-letsencrypt.sh
# ์•„๋ž˜์˜ ๋‚ด์šฉ ๋ณ€๊ฒฝ
domains="<๋„๋ฉ”์ธ ip ๋˜๋Š” ์ด๋ฆ„>" # <>๊ด„ํ˜ธ๋Š” ์ง€์šฐ๊ณ  ""๋Š” ๊ธธ ๊ฒƒ
email="<์ด๋ฉ”์ผ>" # <>๊ด„ํ˜ธ๋Š” ์ง€์šฐ๊ณ  ""๋Š” ๊ธธ ๊ฒƒ
  1. ์œ„์—์„œ ์ˆ˜์ •ํ•œ init-letsencrypt.sh ํŒŒ์ผ ์‹คํ–‰
./init-letsencrypt.sh

# IMPORTANT NOTES: - Congratulations! ๊ฐ€ ๋– ์•ผ ์ •์ƒ์ ์œผ๋กœ ์ธ์ฆ์„œ๊ฐ€ ๋ฐœ๊ธ‰๋œ ๊ฒƒ
  1. NGINX ์„œ๋ฒ„ ์„ค์ • ์ถ”๊ฐ€
vi /opt/nginx/conf.d/app.conf

# ์•„๋ž˜์˜ ๋‚ด์šฉ ๋ณต์‚ฌ ๋ฐ <> ๋‚ด์šฉ ๋ณ€๊ฒฝ, <>๊ด„ํ˜ธ๋„ ์ง€์šธ ๊ฒƒ
server {
    listen <ํฌํŠธ ๋ฒˆํ˜ธ>;
    listen [::]:<ํฌํŠธ ๋ฒˆํ˜ธ>;

    server_name <๋„๋ฉ”์ธ ip ๋˜๋Š” ์ด๋ฆ„>;

    location /.well-known/acme-challenge/ {
            allow all;
            root /var/www/certbot;
    }

    location / {
        return 301 <๋„๋ฉ”์ธ ip ๋˜๋Š” ์ด๋ฆ„>$request_uri;
    }
}

server {
    listen <ํฌํŠธ ๋ฒˆํ˜ธ> ssl;
    server_name <๋„๋ฉ”์ธ ip ๋˜๋Š” ์ด๋ฆ„>;

    ssl_certificate /etc/letsencrypt/live/<๋„๋ฉ”์ธ ip ๋˜๋Š” ์ด๋ฆ„>/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/<๋„๋ฉ”์ธ ip ๋˜๋Š” ์ด๋ฆ„>/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        proxy_pass http://springboot:<ํฌํŠธ ๋ฒˆํ˜ธ>;
        proxy_set_header    Host                $http_host;
        proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    }
}

docker-compose up --build -d nginx # NGINX ์žฌ์‹œ์ž‘

์ฐธ๊ณ  ๋ฌธ์„œ

ํ…Œ์ŠคํŠธ ์ฝ”๋“œ