@ install nginx
sudo apt-get -y install nginx
@ nginx path
cd /etc/nginx/sites-available
sudo vi default
@ nginx default.conf setting
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
// html파일 접근시
location ~ \.(html)$ {
root /var/www/html;
}
// xml파일 접근시
location ~ \.(xml)$ {
root /var/www/xml;
}
}
@ allow Nginx
sudo ufw allow 'Nginx Full'
@ nginx server block
sudo vi /etc/nginx/nginx.conf
http {} 안에 아래와 같이 추가
// sites-enabled 디렉토리에서 서버 블록을 찾도록 지시
include /etc/nginx/sites-enabled/*.conf;
// 도메인이름 분석하는데 할당되는 메모리 양
server_names_hash_bucket_size 64;
@ nginx enable block file
sudo ln -s /etc/nginx/sites-available/[file].conf /etc/nginx/sites-enabled/[file].conf
@ nginx status & restart
sudo systemctl status nginx
sudo systemctl restart nginx
@ log
sudo ls /var/log/nginx // access.log error.log
sudo tail -f /var/log/nginx/access.log