1. NGINX as a Reverse Proxy
root๊ถํ์ผ๋ก application์ ์คํํ๋ ๊ฑด ๊ถ์ฅํ์ง ์๋๋ค.
NGNIX๋ฅผ ์ด์ฉํด ํ๋ก์ ์๋ฒ๋ฅผ ๋์.
# default๋ก ์ค์น ๋ apache2 ์ ๊ฑฐ
sudo apt remove apache2
sudo apt purge apache2
sudo apt install nginx
# ํฌํธ ํ์ฉ
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
# ๋ฐฉํ๋ฒฝ ํ์ฑํ
sudo ufw enable
sudo ufw status
2. NGINX ์ค์ ํ์ผ ๋ณ๊ฒฝ
sudo vi /etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
sudo vi /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# ํฌํธ ํฌ์๋ฉ ์ค์
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
sudo systemctl restart nginx
Nginx ์ฝ๋
# ์ค์ ํ์ผ์ ๊ฒ์ฌํ์ฌ ๊ตฌ๋ฌธ ์ค๋ฅ๊ฐ ์๋์ง ํ์ธ
sudo nginx -t
# nginx์ error.log ํ์ผ์ ์ค์๊ฐ์ผ๋ก ๋ชจ๋ํฐ๋ง
tail -f /var/log/nginx/error.log
3. LetsEncrypt ์ ์ฉ
sudo apt-get install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
# 90์ผ ๋ฐ์ ์๋๋ ์๋ ์ฌ์์ฑ ์ฝ๋
sudo certbot renew
https๋ก ๋ฆฌ๋ค์ด๋ ํธ ์ฝ๋๋ธ๋ญ ๊ต์ฒด
server {
listen 80;
listen [::]:80;
server_name wiseprint.cloud www.wiseprint.cloud;
return 301 https://$host$request_uri;
}
๋ฐ์ํ
'๐ DevOps > ๐ AWS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
EC2์ ROUTE 53 ๋๋ฉ์ธ ์ฐ๊ฒฐ (0) | 2021.04.12 |
---|---|
AWS ์ธ์ฆ์: AWS Certificage Manager (0) | 2021.04.12 |
Elastic IP ํ๋ ฅ์ IP ์ค๋ช , ๋น์ฉ (0) | 2021.04.12 |
http -> https ๋ฆฌ๋ค์ด๋ ํธ ํด๊ฒฐ (node js, helmet ๋ชจ๋) (0) | 2021.04.08 |
Amazone EC2๋ฅผ ์ด์ฉํ ๋ฐฐํฌ (์ธ์คํด์ค ์์ฑ ~ ์ด์ ๋ฐ์) (0) | 2021.04.01 |