Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs : EC2, Nginx, PM2, Express 배포 #44

Closed
unchaptered opened this issue Sep 2, 2022 · 1 comment
Closed

Docs : EC2, Nginx, PM2, Express 배포 #44

unchaptered opened this issue Sep 2, 2022 · 1 comment
Assignees
Labels
documentation 기술 및 에러 해결 문서
Milestone

Comments

@unchaptered
Copy link
Member

unchaptered commented Sep 2, 2022

로그인 기능 구현을 했습니다.

1 주차 프로토타입 배포 간에 사용한 스크립트를 정리한 문서입니다.
해당 되는 pre-release 는 Prototype@1.1.0, PR #43 으로 아래 링크를 확인해주세요.

Nginx + Express 사용 설정

직전에 작성해 두었던 문서와 프로젝트 Issue 를 기반으로 제작되었습니다.

https://velog.io/@unchapterd/%EA%B5%AC%ED%98%84-Reverse-Proxy-Server
https://github.com/motd-5/motd-backend/blob/main/docs/technique/aws/Nginx%20%2B%20Express%20%EC%82%AC%EC%9A%A9%20%EC%84%A4%EC%A0%95.md

CloneCoding-Pinterest/PinterestBE#18

1단계 : AWS 설정

보안 그룹 생성 : 이름 가제 [project-security-group]

  • SSH 22 Anywhere IPv4
  • HTTP 80 Anywhere IPv4
  • 사용자 정의 TCP/IP 3000 Anywhere IPv4

EC2 인스턴스 생성 : 이름 가제 [project-server]

  1. 보안그룹 선택 : project-security-group
  2. SSH 발급 및 저장
  3. *.pem 키 권한 설정 참고글

Node 설치 및 기본설정

curl -s https://deb.nodesource.com/setup_16.x | sudo bash
sudo apt update
sudo apt install nodejs

sudo node -v
sudo npm -v
sudo git -v


sudo npm install pm2 -g
sudo npm ls -g


sudo git clone https://github.com/cupicks/cupicks-be project
ls
cd /home/ubuntu/project
sudo npm ci

sudo nano .env

-- Ctrl + O > Enter : 저장 -- Ctrl + X : 저장이 완료되었을 때는 바로 나와지고, 그렇지 않을 때는 아래 읽어보면 됨...

2단계 : ecosystem.config.js 를 만들어주세요.

3단계 : PEM 생성

openssl genrsa -des3 -out private.pem 2048
openssl rsa -in private.pem -outform PEM -pubout -out public.pem

4단계 : Nginx

sudo apt install nginx
cd /etc/nginx/sites-enabled
sudo nano 도메인-주소
server {

	 listen 80;
   	 listen [::]:80;

	location / {
    		proxy_pass http://127.0.0.1:3000;
  	}

}
cd /etc/nginx
sudo nano nginx.conf
  1. # server_names_hash_bucket_size 64; 구문을 찾아서 # 주석 표시용 문구를 지워주세요
  2. include /etc/nginx/sites-enabled/*; 구문을 찾아서 include /etc/nginx/sites-enabled/도메인-주소; 로 변경해주세요.
  3. client_max_body_size 10M; 구문을 /etc/nginx.conf 의 http 블록 안에 추가헤주세요.
@unchaptered
Copy link
Member Author

5 단계 : Certbot

sudo certbot --nginx -d 도메인-주소

이후 등록되어 있는 이메일 을 입력하면 자동으로 연결이 됩니다.

단, DNS 시스템의 도메인-주소 에 EC2 인스턴스의 IPv4 주소 등록을 해야 합니다.

@unchaptered unchaptered changed the title Docs : EC2, Express 초기 배포 Docs : EC2, Nginx, PM2, Express 배포 Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 기술 및 에러 해결 문서
Projects
None yet
Development

No branches or pull requests

2 participants