43 lines
1.1 KiB
Bash
43 lines
1.1 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
DOMAIN="${1:-birdcam.letteka.com}"
|
|
SERVICE_PORT=8000
|
|
|
|
echo "Configuring nginx for $DOMAIN..."
|
|
|
|
sudo tee /etc/nginx/sites-available/birdcam > /dev/null <<EOF
|
|
server {
|
|
listen 80;
|
|
server_name ${DOMAIN} _;
|
|
|
|
# proxy to gunicorn
|
|
location / {
|
|
proxy_pass http://127.0.0.1:${SERVICE_PORT};
|
|
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;
|
|
proxy_read_timeout 300s;
|
|
}
|
|
|
|
# serve HLS segments directly — bypasses gunicorn entirely
|
|
location /camera/hls/ {
|
|
alias /tmp/hls/;
|
|
add_header Cache-Control no-cache;
|
|
add_header Access-Control-Allow-Origin *;
|
|
types {
|
|
application/vnd.apple.mpegurl m3u8;
|
|
video/mp2t ts;
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
|
|
sudo ln -sf /etc/nginx/sites-available/birdcam \
|
|
/etc/nginx/sites-enabled/birdcam
|
|
sudo rm -f /etc/nginx/sites-enabled/default
|
|
sudo nginx -t
|
|
sudo systemctl reload nginx
|
|
|
|
echo "nginx configured — listening on port 80" |