# Parameters: # radio name # file path # ws port (local) # wss port (open) # upload service port # ssl certs location # TODO # /speedtest-down returns random data # can use : openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero > randomfile.bin # /speedtest-up just eat everything it can map $http_upgrade $connection_upgrade { default upgrade; '' close; } server{ listen $WEBSOCKET_PORT ssl; listen [::]:$WEBSOCKET_PORT ssl; ssl_certificate /etc/letsencrypt/live/$RADIO_HOST/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/$RADIO_HOST/privkey.pem; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://localhost:$WEBSOCKET_CLEAR_PORT; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 120s; } } server { listen 443 ssl; listen [::]:443 ssl; server_name $RADIO_HOST; ssl_certificate /etc/letsencrypt/live/$RADIO_HOST/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/$RADIO_HOST/privkey.pem; root $SOUNDBASE_DIR/website; index index.html; add_header Access-Control-Allow-Origin https://radio.karnaval.fr; location = /direct.ogg { proxy_pass http://172.29.0.110:8000/direct.ogg; # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; } location = /direct.mp3 { proxy_pass http://172.29.0.110:8000/direct.mp3; # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; } location = /api { rewrite ^ /api/; } location ~ /api/pigeindex(/.*) { include uwsgi_params; uwsgi_param PATH_INFO "/pigeindex$1"; uwsgi_param SCRIPT_NAME /api; uwsgi_pass unix:/tmp/uwsgi/$RADIO_HOST/uwsgi-api.sock; client_max_body_size 0; uwsgi_connect_timeout 6000; uwsgi_send_timeout 6000; uwsgi_read_timeout 6000; send_timeout 6000; # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; add_header Access-Control-Allow-Origin https://radio.karnaval.fr; if_modified_since off; expires off; etag off; } location ~ /api(/.*) { auth_basic "Entrez votre identifiant et mot de passe"; auth_basic_user_file $SOUNDBASE_DIR/users.htpasswd; include uwsgi_params; uwsgi_param PATH_INFO "$1"; uwsgi_param SCRIPT_NAME /api; uwsgi_pass unix:/tmp/uwsgi/$RADIO_HOST/uwsgi-api.sock; client_max_body_size 0; proxy_connect_timeout 6000; proxy_send_timeout 60000; proxy_read_timeout 6000; send_timeout 6000; # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; add_header Access-Control-Allow-Origin https://radio.karnaval.fr; if_modified_since off; expires off; etag off; } location /pige{ alias $SOUNDBASE_DIR/pige; try_files $uri $uri/ =404; } location /pigeMp3{ alias $SOUNDBASE_DIR/pigeMp3; try_files $uri $uri/ =404; } location /png { alias $SOUNDBASE_DIR/png; try_files $uri $uri/ =404; } location /webpL { alias $SOUNDBASE_DIR/webpL; try_files $uri $uri/ =404; } location /webpH { alias $SOUNDBASE_DIR/webpH; try_files $uri $uri/ =404; } location /ogg { alias $SOUNDBASE_DIR/ogg; try_files $uri $uri/ =404; } location /txt { # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; add_header Access-Control-Allow-Origin https://radio.karnaval.fr; if_modified_since off; expires off; etag off; alias $SOUNDBASE_DIR/txt; try_files $uri $uri/ =404; } location /wavM { # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; alias $SOUNDBASE_DIR/wavM; try_files $uri $uri/ =404; } location /import { # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; alias $SOUNDBASE_DIR/import; try_files $uri $uri/ =404; } location /export { # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; alias $SOUNDBASE_DIR/export; try_files $uri $uri/ =404; } location /wav { # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; alias $SOUNDBASE_DIR/wav; try_files $uri $uri/ =404; } location /fiches { alias $SOUNDBASE_DIR/fiches; try_files $uri $uri/ =404; # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; add_header Access-Control-Allow-Origin https://radio.karnaval.fr; if_modified_since off; expires off; etag off; } location /prg { # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; alias $SOUNDBASE_DIR/prg; try_files $uri $uri/ =404; } location /listes { # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; alias $SOUNDBASE_DIR/listes; try_files $uri $uri/ =404; } location /statique { alias $SOUNDBASE_DIR/statique; try_files $uri $uri/ =404; # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; add_header Access-Control-Allow-Origin https://radio.karnaval.fr; if_modified_since off; expires off; etag off; } # Admin interface location /manager { auth_basic "Entrez votre identifiant et mot de passe"; auth_basic_user_file $SOUNDBASE_DIR/users.htpasswd; try_files $uri $uri/ =404; } location = /favicon.ico { return 301 /favicon.webp; } # for js, css, html — dynamic site, players location / { try_files $uri $uri/ =404; add_header Cache-Control 'public must-revalidate'; add_header Access-Control-Allow-Origin https://radio.karnaval.fr; } }