# /etc/nginx/sites-available/bct   (then: ln -s ../sites-available/bct /etc/nginx/sites-enabled/)
# After DNS points here, run:  sudo certbot --nginx -d bandjouncommunitytexas.org -d www.bandjouncommunitytexas.org
# certbot adds the HTTPS (443) block and the http->https redirect automatically.

server {
    listen 80;
    server_name bandjouncommunitytexas.org www.bandjouncommunitytexas.org;

    client_max_body_size 300M;          # match max_upload_mb in settings.ini

    # serve photos directly (faster than going through Python)
    location /media/ {
        alias /opt/bct/uploads/;
        expires 30d;
        add_header Cache-Control "public";
        access_log off;
    }
    location /static/ {
        alias /opt/bct/static/;
        expires 7d;
        access_log off;
    }

    location / {
        proxy_pass http://127.0.0.1:8085;   # port from settings.ini
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $host;
        proxy_read_timeout 300s;
        proxy_send_timeout 300s;
    }
}

# Once HTTPS works, send www to the main domain by adding to the 443 server block:
#   if ($host = www.bandjouncommunitytexas.org) { return 301 https://bandjouncommunitytexas.org$request_uri; }
