# 접근한 유저 타입 확인
# check user agent
if ($http_user_agent ~* '(iPhone|iPod|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)') {
set $ua_type "@mobile";
}
# 모바일 기기로 접근시 80 port로 이동
if ($ua_type = "@mobile"){
proxy_pass http://127.0.0.1:80;
}
# PC로 접근시 9001 port로 이동
if ($ua_type != "@mobile"){
proxy_pass http://127.0.0.1:9001;
}
HTTPS 전체 server 설정
server {
listen 443 ssl;
server_name ${도메인명};
ssl_certificate fullchain.pem;
ssl_certificate_key privkey.pem;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# check user agent
if ($http_user_agent ~* '(iPhone|iPod|Opera Mini|Android.*Mobile|NetFront|PSP|BlackBerry|Windows Phone)') {
set $ua_type "@mobile";
}
location / {
if ($ua_type = "@mobile"){
proxy_pass http://127.0.0.1:80;
}
if ($ua_type != "@mobile"){
proxy_pass http://127.0.0.1:9001;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root ${nginx 경로}/html;
}
}