[CowAPI] 32. AWS에 Springboot 배포하기 (2)

준돌·2022년 7월 12일
0

오늘의 Cow

목록 보기
37/45

1. jenkins 시작

  1. 초기는 제 블로그 참고

  2. Pipeline 작성

# JenkinsFile

echo "---build start---"

node {
    stage('Clone') {
        echo '>>> Git repository Clone'
        git branch: 'dev', credentialsId: 'qawesdxc@naver.com' , url: 'https://github.com/Oh-JunYoung/CowAPI.git'
    }
}
  1. Pipeline 생성

  1. git clone -> build -> test -> deploy 잘 되다가 permission denied 문제 해결 x

2. nginx

sudo vi /etc/nginx/nginx.conf

...

include /etc/nginx/conf.d/*.conf;
(✨ 코드 추가) include /etc/nginx/sites-enabled/*.conf;

# server {
#    listen       80 default_server;
#    listen       [::]:80 default_server;
#    server_name  _;
#    root         /usr/share/nginx/html;
    # Load configuration files for the default server block.
#    include /etc/nginx/default.d/*.conf;
#    location / {
#    }
#    error_page 404 /404.html;
#        location = /40x.html {
#    }
#    error_page 500 502 503 504 /50x.html;
#        location = /50x.html {
#    }
# }

...
sudo mkdir /etc/nginx/sites-available
sudo mkdir /etc/nginx/sites-enabled
sudo vi /etc/nginx/sites-available/#######.conf
server {
  listen 80;

  server_name cowapi.com www.cowapi.com; # 도메인이 있을 경우
  
  location = /favicon.ico {access_log off; log_not_found off;}

  location / {
    root /home/ec2-user/#######/#######/build;
    index	index.html index.htm;
    try_files 	$uri $uri/ /index.html;

    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_set_header X-Nginx-Proxy true;
    proxy_redirect off;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

sudo ln -s /etc/nginx/sites-available/cowapi.conf /etc/nginx/sites-enabled/

chmod 711 /home/ec2-user
sudo systemctl start nginx # 기동
sudo systemctl stop nginx # 정지
sudo systemctl restart nginx # 재시작
nginx -t # 엔진 엑스 테스트

/etd/nginx # main 설정파일 위치
/etc/nginx/conf.d/ # 각 서버용 설정파일 위치
profile
눈 내리는 겨울이 좋아!

0개의 댓글