Nginx 설정: 특정 IP에 대해 HTTP 유지
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
server {
listen 80;
server_name yourdomain.com;
# 특정 IP는 HTTP 그대로
set $redirect_to_https 1;
# 특정 IP 목록 (예: 192.168.0.1)
if ($remote_addr = 192.168.0.1) {
set $redirect_to_https 0;
}
# 조건에 따라 HTTPS로 리다이렉션
if ($redirect_to_https = 1) {
return 301 https://$host$request_uri;
}
# 이 아래는 허용된 IP의 HTTP 처리
location / {
# 여기에 HTTP로 서비스할 내용
return 200 "You are using HTTP from an allowed IP.\n";
}
}
server {
listen 443 ssl;
server_name yourdomain.com;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
location / {
# HTTPS 처리
return 200 "You are using HTTPS.\n";
}
}
This post is licensed under CC BY 4.0 by the author.