Skip to content

Commit 1ffd013

Browse files
committed
nginx+ssl install
1 parent 1f273b2 commit 1ffd013

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
layout : post
3+
title : Ubuntu24.04 Nginx install + ssl
4+
tags: [linux,config]
5+
---
6+
7+
## apt install
8+
9+
```bash
10+
sudo apt list --upgradable
11+
sudo apt update
12+
sudo apt upgrade -y
13+
sudo apt install nginx -y
14+
sudo apt install certbot python3-certbot-nginx -y
15+
```
16+
17+
## nginx custom config
18+
19+
```bash
20+
sudo cat > /etc/nginx/sites-available/host.com
21+
22+
server {
23+
listen 80;
24+
server_name host.com;
25+
26+
# HTTPS로 리디렉션
27+
return 301 https://$host$request_uri;
28+
}
29+
30+
server {
31+
listen 443 ssl http2;
32+
server_name host.com;
33+
34+
ssl_certificate /etc/letsencrypt/live/host.com/fullchain.pem;
35+
ssl_certificate_key /etc/letsencrypt/live/host.com/privkey.pem;
36+
ssl_protocols TLSv1.2 TLSv1.3;
37+
ssl_ciphers HIGH:!aNULL:!MD5;
38+
39+
# 프록시 설정
40+
location / {
41+
proxy_pass http://localhost:3000;
42+
proxy_http_version 1.1;
43+
proxy_set_header X-Real-IP $remote_addr;
44+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45+
proxy_set_header X-Forwarded-Proto $scheme;
46+
proxy_set_header Upgrade $http_upgrade;
47+
proxy_set_header Connection 'upgrade';
48+
proxy_set_header Host $host;
49+
proxy_cache_bypass $http_upgrade;
50+
}
51+
# 로그
52+
access_log /var/log/nginx/host_access.log;
53+
error_log /var/log/nginx/host_error.log;
54+
}
55+
```
56+
57+
## nginx systemd setting
58+
59+
```bash
60+
sudo nginx -t
61+
sudo systemctl restart nginx
62+
sudo certbot --nginx
63+
sudo certbot renew --dry-run
64+
```

0 commit comments

Comments
 (0)