fix(nginx): cleanup all nginx config files NOCHANGELOG

environments/review-docs-renov-k6e5t2/deployments/15588
JuniorJPDJ 2022-11-22 19:23:13 +00:00
rodzic 67759d3498
commit ae53cf4cf0
6 zmienionych plików z 134 dodań i 126 usunięć

Wyświetl plik

@ -0,0 +1 @@
../docker/nginx/conf.dev

Wyświetl plik

@ -0,0 +1 @@
../front/docker/funkwhale.conf.template

Wyświetl plik

@ -1,4 +1,4 @@
# This file was generated from funkwhale.template # This file was generated from Funkwhale's nginx.template
upstream funkwhale-api { upstream funkwhale-api {
# depending on your setup, you may want to update this # depending on your setup, you may want to update this
@ -10,12 +10,18 @@ server {
listen [::]:80; listen [::]:80;
# update this to match your instance name # update this to match your instance name
server_name ${FUNKWHALE_HOSTNAME}; server_name ${FUNKWHALE_HOSTNAME};
# useful for Let's Encrypt # useful for Let's Encrypt
location /.well-known/acme-challenge/ { allow all; } location /.well-known/acme-challenge/ {
location / { return 301 https://$host$request_uri; } allow all;
}
location / {
return 301 https://$host$request_uri;
}
} }
# required for websocket support # Required for websocket support.
map $http_upgrade $connection_upgrade { map $http_upgrade $connection_upgrade {
default upgrade; default upgrade;
'' close; '' close;
@ -24,6 +30,7 @@ map $http_upgrade $connection_upgrade {
server { server {
listen 443 ssl http2; listen 443 ssl http2;
listen [::]:443 ssl http2; listen [::]:443 ssl http2;
charset utf-8;
server_name ${FUNKWHALE_HOSTNAME}; server_name ${FUNKWHALE_HOSTNAME};
# TLS # TLS
@ -38,15 +45,14 @@ server {
ssl_session_cache shared:SSL:10m; ssl_session_cache shared:SSL:10m;
ssl_certificate /etc/letsencrypt/live/${FUNKWHALE_HOSTNAME}/fullchain.pem; ssl_certificate /etc/letsencrypt/live/${FUNKWHALE_HOSTNAME}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${FUNKWHALE_HOSTNAME}/privkey.pem; ssl_certificate_key /etc/letsencrypt/live/${FUNKWHALE_HOSTNAME}/privkey.pem;
# HSTS # HSTS
add_header Strict-Transport-Security "max-age=31536000"; add_header Strict-Transport-Security "max-age=31536000";
# If you are using S3 to host your files, remember to add your S3 URL to the add_header Content-Security-Policy "default-src 'self'; connect-src https: wss: http: ws: 'self' 'unsafe-eval'; script-src 'self' 'wasm-unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; media-src https: http: 'self' data:; object-src 'none'";
# media-src and img-src headers (e.g. img-src 'self' https://<your-S3-URL> data:)
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'; img-src 'self' data:; font-src 'self' data:; object-src 'none'; media-src 'self' data:; worker-src 'self'";
add_header Referrer-Policy "strict-origin-when-cross-origin"; add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Frame-Options "SAMEORIGIN" always;
add_header Service-Worker-Allowed "/";
root ${FUNKWHALE_FRONTEND_PATH}; root ${FUNKWHALE_FRONTEND_PATH};
@ -79,29 +85,22 @@ server {
location / { location / {
include /etc/nginx/funkwhale_proxy.conf; include /etc/nginx/funkwhale_proxy.conf;
# this is needed if you have file import via upload enabled # This is needed if you have file import via upload enabled.
client_max_body_size ${NGINX_MAX_BODY_SIZE}; client_max_body_size ${NGINX_MAX_BODY_SIZE};
proxy_pass http://funkwhale-api/; proxy_pass http://funkwhale-api/;
} }
location /front/ { location /front/ {
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; object-src 'none'; media-src 'self' data:; worker-src 'self'";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header Service-Worker-Allowed "/";
alias ${FUNKWHALE_FRONTEND_PATH}/; alias ${FUNKWHALE_FRONTEND_PATH}/;
expires 30d; expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
} }
location = /front/embed.html { location = /front/embed.html {
add_header Content-Security-Policy "connect-src https: http: 'self' 'wasm-unsafe-eval'; default-src 'self'; script-src 'self' unpkg.com 'unsafe-inline' 'unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; object-src 'none'; media-src https: http: 'self' data:"; add_header Content-Security-Policy "connect-src https: http: 'self'; default-src 'self'; script-src 'self' unpkg.com 'unsafe-inline' 'unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; object-src 'none'; media-src https: http: 'self' data:";
add_header Referrer-Policy "strict-origin-when-cross-origin"; add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Frame-Options "" always;
alias ${FUNKWHALE_FRONTEND_PATH}/embed.html; alias ${FUNKWHALE_FRONTEND_PATH}/embed.html;
expires 30d; expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
} }
location /federation/ { location /federation/ {
@ -109,7 +108,7 @@ server {
proxy_pass http://funkwhale-api/federation/; proxy_pass http://funkwhale-api/federation/;
} }
# You can comment this if you do not plan to use the Subsonic API # You can comment this if you do not plan to use the Subsonic API.
location /rest/ { location /rest/ {
include /etc/nginx/funkwhale_proxy.conf; include /etc/nginx/funkwhale_proxy.conf;
proxy_pass http://funkwhale-api/api/subsonic/rest/; proxy_pass http://funkwhale-api/api/subsonic/rest/;
@ -125,36 +124,27 @@ server {
add_header Access-Control-Allow-Origin '*'; add_header Access-Control-Allow-Origin '*';
} }
location /_protected/media/ { # This is an internal location that is used to serve
# this is an internal location that is used to serve # media (uploaded) files once correct permission / authentication
# audio files once correct permission / authentication # has been checked on API side.
# has been checked on API side # Comment the "NON-S3" commented lines and uncomment "S3" commented lines
# if you're storing media files in a S3 bucket.
location ~ /_protected/media/(.+) {
internal; internal;
alias ${MEDIA_ROOT}; alias ${MEDIA_ROOT}/$1; # NON-S3
# Needed to ensure DSub auth isn't forwarded to S3/Minio, see #932.
# proxy_set_header Authorization ""; # S3
# proxy_pass $1; # S3
add_header Access-Control-Allow-Origin '*'; add_header Access-Control-Allow-Origin '*';
} }
# Comment the previous location and uncomment this one if you're storing
# media files in a S3 bucket
# location ~ /_protected/media/(.+) {
# internal;
# # Needed to ensure DSub auth isn't forwarded to S3/Minio, see #932
# proxy_set_header Authorization "";
# proxy_pass $1;
# }
location /_protected/music/ { location /_protected/music/ {
# this is an internal location that is used to serve # This is an internal location that is used to serve
# audio files once correct permission / authentication # local music files once correct permission / authentication
# has been checked on API side # has been checked on API side.
# Set this to the same value as your MUSIC_DIRECTORY_PATH setting # Set this to the same value as your MUSIC_DIRECTORY_PATH setting.
internal; internal;
alias ${MUSIC_DIRECTORY_SERVE_PATH}; alias ${MUSIC_DIRECTORY_SERVE_PATH};
add_header Access-Control-Allow-Origin '*'; add_header Access-Control-Allow-Origin '*';
} }
location /staticfiles/ {
# django static files
alias ${STATIC_ROOT}/;
}
} }

Wyświetl plik

@ -21,28 +21,34 @@ http {
access_log /var/log/nginx/access.log main; access_log /var/log/nginx/access.log main;
sendfile on; sendfile on;
#tcp_nopush on;
keepalive_timeout 65; keepalive_timeout 65;
#gzip on;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream funkwhale-api { upstream funkwhale-api {
server ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT}; server ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT};
} }
upstream funkwhale-front { upstream funkwhale-front {
server ${FUNKWHALE_FRONT_IP}:${FUNKWHALE_FRONT_PORT}; server ${FUNKWHALE_FRONT_IP}:${FUNKWHALE_FRONT_PORT};
} }
# Required for websocket support.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server { server {
listen 80; listen 80;
listen [::]:80;
charset utf-8; charset utf-8;
client_max_body_size 100M; client_max_body_size ${NGINX_MAX_BODY_SIZE};
include /etc/nginx/funkwhale_proxy.conf; include /etc/nginx/funkwhale_proxy.conf;
add_header Content-Security-Policy "default-src 'self'; connect-src https: wss: http: ws: 'self' 'unsafe-eval'; script-src 'self' 'wasm-unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; media-src https: http: 'self' data:; object-src 'none'";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Service-Worker-Allowed "/";
# compression settings # compression settings
gzip on; gzip on;
gzip_comp_level 5; gzip_comp_level 5;
@ -68,73 +74,71 @@ http {
text/vtt text/vtt
text/x-component text/x-component
text/x-cross-domain-policy; text/x-cross-domain-policy;
# end of compression settings
add_header Content-Security-Policy "connect-src https: wss: http: ws: 'self' 'unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; object-src 'none'; media-src https: http: 'self' data:";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Frame-Options "SAMEORIGIN" always;
location /front/ {
add_header Content-Security-Policy "connect-src https: wss: http: ws: 'self' 'unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; object-src 'none'; media-src https: http: 'self' data:";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header Service-Worker-Allowed "/";
# uncomment the following line and comment the proxy-pass one
# to use the frontend build with "yarn build"
#alias /frontend/dist/;
proxy_pass http://funkwhale-front/front/;
}
location /front/embed.html {
add_header Content-Security-Policy "connect-src https: http: 'self'; default-src 'self'; script-src 'self' unpkg.com 'unsafe-inline' 'unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; object-src 'none'; media-src https: http: 'self' data:";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Frame-Options "" always;
proxy_pass http://funkwhale-front/front/embed.html;
}
location / { location / {
include /etc/nginx/funkwhale_proxy.conf; include /etc/nginx/funkwhale_proxy.conf;
# this is needed if you have file import via upload enabled # This is needed if you have file import via upload enabled.
client_max_body_size ${NGINX_MAX_BODY_SIZE}; client_max_body_size ${NGINX_MAX_BODY_SIZE};
proxy_pass http://funkwhale-api/; proxy_pass http://funkwhale-api/;
} }
# You can comment this if you do not plan to use the Subsonic API location /front/ {
proxy_pass http://funkwhale-front/front/;
expires 1d;
}
location = /front/embed.html {
add_header Content-Security-Policy "connect-src https: http: 'self'; default-src 'self'; script-src 'self' unpkg.com 'unsafe-inline' 'unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; object-src 'none'; media-src https: http: 'self' data:";
add_header Referrer-Policy "strict-origin-when-cross-origin";
proxy_pass http://funkwhale-front/front/embed.html;
expires 1d;
}
location /federation/ {
include /etc/nginx/funkwhale_proxy.conf;
proxy_pass http://funkwhale-api/federation/;
}
# You can comment this if you do not plan to use the Subsonic API.
location /rest/ { location /rest/ {
include /etc/nginx/funkwhale_proxy.conf; include /etc/nginx/funkwhale_proxy.conf;
proxy_pass http://funkwhale-api/api/subsonic/rest/; proxy_pass http://funkwhale-api/api/subsonic/rest/;
} }
location /.well-known/ {
include /etc/nginx/funkwhale_proxy.conf;
proxy_pass http://funkwhale-api/.well-known/;
}
location /media/ { location /media/ {
alias /protected/media/; alias /protected/media/;
add_header Access-Control-Allow-Origin '*';
} }
# this is an internal location that is used to serve # This is an internal location that is used to serve
# audio files once correct permission / authentication # media (uploaded) files once correct permission / authentication
# has been checked on API side # has been checked on API side.
location /_protected/media { # Comment the "NON-S3" commented lines and uncomment "S3" commented lines
# if you're storing media files in a S3 bucket.
location ~ /_protected/media/(.+) {
internal; internal;
alias /protected/media; alias /protected/media/$1; # NON-S3
# Needed to ensure DSub auth isn't forwarded to S3/Minio, see #932.
# proxy_set_header Authorization ""; # S3
# proxy_pass $1; # S3
add_header Access-Control-Allow-Origin '*';
} }
# Comment the previous location and uncomment this one if you're storing
# media files in a S3 bucket
# location ~ /_protected/media/(.+) {
# internal;
# resolver 127.0.0.11;
# # Needed to ensure DSub auth isn't forwarded to S3/Minio, see #932
# proxy_set_header Authorization "";
# proxy_set_header X-Remote-URL "$1";
# proxy_pass $1;
# }
location /_protected/music { location /_protected/music/ {
# this is an internal location that is used to serve # This is an internal location that is used to serve
# audio files once correct permission / authentication # local music files once correct permission / authentication
# has been checked on API side # has been checked on API side.
# Set this to the same value as your MUSIC_DIRECTORY_PATH setting # Set this to the same value as your MUSIC_DIRECTORY_PATH setting.
internal; internal;
alias /music; alias /music/;
} add_header Access-Control-Allow-Origin '*';
location /staticfiles/ {
alias /staticfiles/;
} }
} }
} }

Wyświetl plik

@ -26,4 +26,3 @@ RUN mkdir -p /var/log/nginx /var/cache/nginx /var/run/nginx && \
ENV FUNKWHALE_API_HOST=api ENV FUNKWHALE_API_HOST=api
ENV FUNKWHALE_API_PORT=5000 ENV FUNKWHALE_API_PORT=5000
ENV AWS_S3_ENDPOINT_URL=

Wyświetl plik

@ -2,7 +2,6 @@ upstream funkwhale-api {
server ${FUNKWHALE_API_HOST}:${FUNKWHALE_API_PORT}; server ${FUNKWHALE_API_HOST}:${FUNKWHALE_API_PORT};
} }
# Required for websocket support. # Required for websocket support.
map $http_upgrade $connection_upgrade { map $http_upgrade $connection_upgrade {
default upgrade; default upgrade;
@ -10,17 +9,44 @@ map $http_upgrade $connection_upgrade {
} }
server { server {
listen 80; listen 80;
server_name ${FUNKWHALE_HOSTNAME}; listen [::]:80;
charset utf-8;
server_name _;
add_header Content-Security-Policy "default-src 'self'; connect-src https: wss: http: ws: 'self' 'unsafe-eval'; script-src 'self' 'wasm-unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; media-src https: http: 'self' data:; object-src 'none'";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Service-Worker-Allowed "/";
root /usr/share/nginx/html; root /usr/share/nginx/html;
# If you are using S3 to host your files, remember to add your S3 URL to the # compression settings
# media-src and img-src headers (e.g. img-src 'self' https://<your-S3-URL> data:). gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' ${AWS_S3_ENDPOINT_URL} data:; font-src 'self' data:; object-src 'none'; media-src ${AWS_S3_ENDPOINT_URL} 'self' data:"; gzip_types
add_header Referrer-Policy "strict-origin-when-cross-origin"; application/javascript
add_header X-Frame-Options "SAMEORIGIN" always; application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# end of compression settings
location / { location / {
include /etc/nginx/funkwhale_proxy.conf; include /etc/nginx/funkwhale_proxy.conf;
@ -30,24 +56,16 @@ server {
} }
location /front/ { location /front/ {
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' ${AWS_S3_ENDPOINT_URL} data:; font-src 'self' data:; object-src 'none'; media-src ${AWS_S3_ENDPOINT_URL} 'self' data:";
add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header Service-Worker-Allowed "/";
alias /usr/share/nginx/html/; alias /usr/share/nginx/html/;
expires 30d; expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
} }
location = /front/embed.html { location = /front/embed.html {
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' ${AWS_S3_ENDPOINT_URL} data:; font-src 'self' data:; object-src 'none'; media-src ${AWS_S3_ENDPOINT_URL} 'self' data:"; add_header Content-Security-Policy "connect-src https: http: 'self'; default-src 'self'; script-src 'self' unpkg.com 'unsafe-inline' 'unsafe-eval'; style-src https: http: 'self' 'unsafe-inline'; img-src https: http: 'self' data:; font-src https: http: 'self' data:; object-src 'none'; media-src https: http: 'self' data:";
add_header Referrer-Policy "strict-origin-when-cross-origin"; add_header Referrer-Policy "strict-origin-when-cross-origin";
add_header X-Frame-Options "" always;
alias /usr/share/nginx/html/embed.html; alias /usr/share/nginx/html/embed.html;
expires 30d; expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
} }
location /federation/ { location /federation/ {
@ -94,9 +112,4 @@ server {
alias ${MUSIC_DIRECTORY_PATH}/; alias ${MUSIC_DIRECTORY_PATH}/;
add_header Access-Control-Allow-Origin '*'; add_header Access-Control-Allow-Origin '*';
} }
location /staticfiles/ {
# Django static files
alias ${STATIC_ROOT}/;
}
} }