# TaxBaik Nginx 설정
# https://www.taxbaik.com/ → http://127.0.0.1:5001/

server {
    server_name taxbaik.com www.taxbaik.com;
    client_max_body_size 512M;

    location / {
        proxy_pass http://127.0.0.1:5001/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        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_read_timeout 120s;
    }

    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/taxbaik.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/taxbaik.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}

server {
    if ($server_name = www.taxbaik.com) {
        return 301 https://$server_name$request_uri;
    }
    if ($server_name = taxbaik.com) {
        return 301 https://$server_name$request_uri;
    }

    listen 80;
    server_name taxbaik.com www.taxbaik.com;
    return 404;
}
