# nginx reverse proxy — fronts the Node app on :3000 and serves it on :80 / :443.
# Install:  sudo cp deploy/nginx-br-cessa.conf /etc/nginx/sites-available/br-cessa
#           sudo ln -s /etc/nginx/sites-available/br-cessa /etc/nginx/sites-enabled/
#           sudo nginx -t && sudo systemctl reload nginx
#
# For HTTPS, obtain a certificate (HKUST ITSC can issue an *.ust.hk cert, or use certbot
# if outbound ACME is permitted) and uncomment the 443 server block.

server {
    listen 80;
    server_name br-cessa.ust.hk 143.89.208.14;

    # Redirect to HTTPS once a certificate is installed:
    # return 301 https://$host$request_uri;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        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;
    }
}

# server {
#     listen 443 ssl http2;
#     server_name br-cessa.ust.hk;
#     ssl_certificate     /etc/ssl/certs/br-cessa.ust.hk.crt;
#     ssl_certificate_key /etc/ssl/private/br-cessa.ust.hk.key;
#     location / {
#         proxy_pass http://127.0.0.1:3000;
#         proxy_http_version 1.1;
#         proxy_set_header Host $host;
#         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;
#     }
# }
