diff --git a/.github/workflows/auto.deploy.yml b/.github/workflows/auto.deploy.yml index a9b9581..9c61098 100644 --- a/.github/workflows/auto.deploy.yml +++ b/.github/workflows/auto.deploy.yml @@ -22,7 +22,7 @@ jobs: run: sh ecosystem.config.json.sh ${{ secrets.NODE_ENV }} ${{ secrets.PORT }} ${{ secrets.SALT }} ${{ secrets.CORS_URL_ONE_WITHOUT_PORT }} ${{ secrets.CORS_URL_TWO_WITHOUT_PORT }} ${{ secrets.CORS_URL_THREE_WITHOUT_PORT }} ${{ secrets.CORS_URL_FOUR_WITHOUT_PORT }} ${{ secrets.FROTN_REDIRECT_URL_WITHOUT_PORT }} ${{ secrets.SERVER_URL_WITH_PORT }} ${{ secrets.JWT_ACCESS_EXPIRED_IN }} ${{ secrets.JWT_REFRESH_EXPIRED_IN }} ${{ secrets.JWT_VERIFY_EXPIRED_IN }} ${{ secrets.JWT_RESET_EXPIRED_IN }} ${{ secrets.JWT_HASH_ALGOIRHTM }} ${{ secrets.HASH_PASSPHRASE }} ${{ secrets.MYSQL_HOST }} ${{ secrets.MYSQL_USER }} ${{ secrets.MYSQL_DATABASE }} ${{ secrets.MYSQL_PASSWORD }} ${{ secrets.MYSQL_CONNECTION_LIMIT }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }} ${{ secrets.BUCKET }} ${{ secrets.REGION }} ${{ secrets.SES_API_VERSION }} ${{ secrets.SES_API_REGION }} ${{ secrets.SES_ACCESS_KEY }} ${{ secrets.SES_SECRET_KEY }} ${{ secrets.SES_SENDER_EMAIL }} ${{ secrets.MYSQL_HOST }} - name: Zip file - run: zip -r ${{github.event.pull_request.timestamp}}_server.zip .github/workflows ./scripts ./jest ./src ./test ./appspec.yml ./gitignore ./package.json ./package-lock.json ./tsconfig.build.json ./tsconfig.json ./jest.config.json ./ecosystem.config.json + run: zip -r ${{github.event.pull_request.timestamp}}_server.zip .github/workflows ./scripts ./content ./jest ./src ./test ./appspec.yml ./gitignore ./package.json ./package-lock.json ./tsconfig.build.json ./tsconfig.json ./jest.config.json ./ecosystem.config.json - name: AWS configure credentials uses: aws-actions/configure-aws-credentials@v1 diff --git a/appspec.yml b/appspec.yml index 164c95a..749ef42 100644 --- a/appspec.yml +++ b/appspec.yml @@ -15,7 +15,7 @@ permissions: hooks: AfterInstall: - - location: scripts/after-deploy.sh + - location: scripts/after-install.sh timeout: 300 runas: ubuntu # runas는 사용자 이름 \ No newline at end of file diff --git a/content/nginx/cupick.ddns.net b/content/nginx/cupick.ddns.net new file mode 100644 index 0000000..5cdbe30 --- /dev/null +++ b/content/nginx/cupick.ddns.net @@ -0,0 +1,45 @@ +server { + + server_name cupick.ddns.net; + + location / { + + # Connect to ReadReplica RDS + if ($request_method = GET) { + + proxy_pass http://127.0.0.1:3001; + } + + # Connect to Origin RDS + proxy_pass http://127.0.0.1:3000; + } + + listen [::]:443 ssl ipv6only=on; # managed by Certbot + listen 443 ssl; # managed by Certbot + + ssl_certificate /etc/letsencrypt/live/cupick.ddns.net/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/cupick.ddns.net/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + +} + +server { + if ($host = cupick.ddns.net) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + + listen 80; + listen [::]:80; + + server_name cupick.ddns.net; + + #location / { + # return 301 https://cupick.ddns.net$request_uri; + #} + return 404; # managed by Certbot + + +} \ No newline at end of file diff --git a/scripts/after-deploy.sh b/scripts/after-install.sh similarity index 55% rename from scripts/after-deploy.sh rename to scripts/after-install.sh index ce142d0..d232c01 100644 --- a/scripts/after-deploy.sh +++ b/scripts/after-install.sh @@ -3,6 +3,9 @@ REPOSITORY=/home/ubuntu/project cd $REPOSITORY +sudo cp content/nginx/cupick.ddns.net /etc/nginx/sites-enabled/cupick.ddns.net +sudo service nginx reload + sudo npm install # sudo pm2 kill