2023.12.14 next EC2 배포법

이무헌·2023년 12월 14일
0

AWS

목록 보기
3/3

1.Next 서버 실행

ec2 우분투내에서 git pull을 받은 후 npm run build 와 npm run start를 하면 서버가 생성된다.
기본값은 http://127.0.0.1:3000 이며 도메인이 없을시 탄력적 ip로 바로 배포된 사이트를 볼 수 있다.

2.nginx(default)설정

server_name domain.com;
location / {
proxy_set_header HOST $host;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
}

SSR이라 redirect off로 하고 #try_files $uri $uri/ =404;을 삭제시켜 계속해서 http://127.0.0.1:3000에 요청을 보내게 하였다.

3.PM2로 실행하기

npm install pm2 -g

pm2 start npm --name "next-app" -- run start

서버 이름을 next-app으로 실행했다.

profile
개발당시에 직면한 이슈를 정리하는 곳

0개의 댓글