본문 바로가기
Etc.

패키지 매니저(저장소)를 구축해보자(Verdaccio) [2]

by parkjp 2023. 9. 2.

 

 

Verdaccio & AWS S3설정하기

 

설치는 지난 편은 참고하기 바란다.

 

https://developer-jp.tistory.com/109

 

패키지 매니저(저장소)를 구축해보자(Verdaccio) [1]

1. 설치 전제조건 Node.js v12 이상 npm, pnpm 또는 yarn ( npm@6.x | yarn@1.x | pnpm@6.x ) 2. Verdaccio 설치 // npm npm install --location=global verdaccio // yarn yarn global add verdaccio // pnpm pnpm install -g verdaccio 3. Verdaccio 사용법

developer-jp.tistory.com

 

 

verdaccio를 설치하면 config.yaml파일이 있다.

해당 파일에 AWS S3와 Nginx 설정을 해보자.

S3를 설정해두면 패키지 파일이 로컬 스토리지에 저장되는게 아닌 S3에 저장된다.

 

우선 AWS S3 플러그인을 설치하자.

npm install verdaccio-aws-s3-storage

 

그리고 Verdaccio의 설정파일 config.yaml을 수정하자.

//Verdaccio config.yaml

store:
  aws-s3-storage:
     bucket: <your-aws-s3-bucket-name>
     region: <region>
     accessKeyId: <your-aws-access-key>
     secretAccessKey: <your-aws-sercet-key>
     endpoint: https://{service}.{region}.amazonaws.com # optional, will use aws s3's default behavior if not specified
     s3ForcePathStyle: false # optional, will use path style URLs for S3 objects
     tarballACL: private # optional, use public-read to work with CDN like Amazon CloudFront
     sessionToken: your-session-token # optional, aws sessionToken for private S3 bucket

 

 

 

Verdaccio & Nginx 설정하기 (SSL 설정)

nginx 설정을 하고나면 restart 해야한다는 것을 잊지 말자.

 

  • Default 설정
server {
    listen 80 default_server;
    access_log /var/log/nginx/verdaccio.log;
    charset utf-8;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $host;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://localhost:4873;
      proxy_redirect off;
    }
}

 

  • SSL 설정 (Certbot)
apt-get update
sudo apt-get install certbot

// 18.04 이하
sudo apt-get install python-certbot-nginx

// 18.04 이상
sudo apt-get install python3-certbot-nginx


sudo certbot --nginx -d <your-domain>
sudo certbot --nginx -d <your-domain> -d <your-subdomain>

 

위 명령어를 잘 따라 했다면 nginx 설정파일에 SSL 설정이 되어있을 것이다.

그 외 부분은 아래 부분을 참고하여 설정하자.

server {
    listen 80;
    return 302 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name <your-domain>;

    ssl on;
    
    ## your certbot did something!!

    location / {
        proxy_set_header    Host $host;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto $scheme;
        proxy_pass          http://localhost:4783;
        proxy_read_timeout  600;
        proxy_redirect off;
    }
}

 

SSL 설정을 하였으면 Verdaccio Config 파일 설정도 바꿔야 되는 부분이 있다.

해당 부분 설정하고 restart해서 적용하자.

url_prefix: '/'
VERDACCIO_PUBLIC_URL: <your-domain> ex) 'https://example.com'

 

반응형