study / okdevtv star
허광남 허광남 2021-09-14
elk nginx
@ea4553bea94d4cfff3025e79a3d44c4ae29333fb
 
sh/deploy-elk.sh (added)
+++ sh/deploy-elk.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+source $HOME/.bash_profile
+DEST=/home/ec2-user/git/10ynews
+cd $DEST/web
+git pull
+npm install --only=production
+
+pm2 restart 10ynews
+
+# curl -X POST -H 'Content-type: application/json' \
+# --data '{"text":"10ynews Deployment Finished!"}' \
+# https://hooks.slack.com/services/xxxxR3xx4/B0xxDNExx11/xxxWeAVFWcFJOoJBxxxx6Bxx
+
+# end
 
sh/elk.conf (added)
+++ sh/elk.conf
@@ -0,0 +1,30 @@
+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 / {
+        sendfile off;
+        proxy_pass         http://127.0.0.1:3010;
+        proxy_redirect     default;
+        proxy_http_version 1.1;
+        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_cache_bypass $http_upgrade;
+        proxy_max_temp_file_size 0;
+    }
+
+    error_page 404 /404.html;
+        location = /40x.html {
+    }
+
+    error_page 500 502 503 504 /50x.html;
+        location = /50x.html {
+    }
+}
 
sh/install-env.sh (added)
+++ sh/install-env.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+REPO=https://github.com/kenu/10ynews
+
+sudo yum install -y git
+curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
+sleep 2
+sudo yum install -y nodejs
+sudo npm i -g npm
+sudo npm i -g pm2
+mkdir ~/git
+cd ~/git
+git clone $REPO
+cp ~/git/10ynews/sh/deploy-10ynews.sh ~
+chmod +x ~/deploy-10ynews.sh
+
+cd 10ynews/web
+npm install --only=production
+pm2 start bin/10ynews
+sleep 2
+pm2 list
+
+sudo amazon-linux-extras install -y nginx1.12
+sudo systemctl enable nginx
+
+sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig
+sudo sh -c "sed '38,87d' /etc/nginx/nginx.conf.orig > /etc/nginx/nginx.conf"
+cd /etc/nginx/conf.d
+sudo curl -O https://raw.githubusercontent.com/kenu/okdevtv/main/sh/elk.conf
+sleep 2
+sudo systemctl start nginx
+
Add a comment
List