OCI 콘솔에서 인스턴스의 보안 목록(Security List)에 다음 규칙을 추가하세요:
| 방향 | 프로토콜 | 소스/대상 | 포트 |
|---|---|---|---|
| Ingress | TCP | 0.0.0.0/0 | 80 |
| Ingress | TCP | 0.0.0.0/0 | 443 |
OCI는 기본적으로 방화벽이 꽤 tight합니다. 이걸 안 하면 접속이 안 됩니다.
# Ubuntu/Debian 기준
sudo apt update && sudo apt upgrade -y
# Oracle Linux/RHEL 기준
sudo dnf update -y
sudo apt install nginx -y
sudo dnf install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx
정상이면 active (running) 이라고 나옵니다.
sudo ufw allow 'Nginx Full'
sudo ufw status
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
curl http://localhost
또는 브라우저에서 http://<공인IP> 접속 → Nginx 환영 페이지가 뜨면 성공.
1GB 메모리는 빠듯하기 때문에 기본 설정을 조정해야 합니다:
sudo nano /etc/nginx/nginx.conf
worker_processes 1; # CPU 1개이므로 1로 설정
events {
worker_connections 256; # 기본 1024 → 256으로 축소
}
http {
# ... 기존 설정 유지 ...
# 메모리 절약 설정
client_body_buffer_size 8k;
client_header_buffer_size 1k;
large_client_header_buffers 2 8k;
client_max_body_size 10m;
# 버퍼 최적화
output_buffers 1 32k;
# Gzip 압축 (CPU vs 메모리 트레이드오프)
gzip on;
gzip_types text/plain text/css application/json application/javascript;
gzip_min_length 256;
}
# 설정 문법 확인
sudo nginx -t
# 적용
sudo systemctl reload nginx
1GB RAM에서 메모리 부족 시 프로세스가 죽는 걸 방지:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# 영구 적용
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
# 확인
free -h
sudo nano /etc/nginx/sites-available/default
server {
listen 80;
server_name _;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
sudo nginx -t
sudo systemctl reload nginx
sudo apt install certbot python3-certbot-nginx -y # Ubuntu
sudo certbot --nginx -d your-domain.com
자동 갱신 확인:
sudo systemctl status certbot.timer
# 서비스 상태
systemctl is-active nginx
# 포트 리스닝 확인
ss -tlnp | grep nginx
# 메모리 사용량
ps aux | grep nginx
# 로그 확인
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
참고: OCI 무료 티어 AMD VM은 1GB RAM이라 트래픽이 많으면 금방 빡빡해집니다. 정적 사이트 위주로 운영하고, 동적 애플리케이션은 별도로 고려하세요.
댓글 영역