From 1955005a4f17ac51e687315e810cfa4150dcd211 Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Sun, 4 Mar 2018 16:58:37 +0100 Subject: [PATCH] Moved commen nginx configuration in a dedicated snippet --- deploy/funkwhale_proxy.conf | 13 +++++++++++++ deploy/nginx.conf | 19 +++---------------- docs/installation/index.rst | 3 ++- 3 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 deploy/funkwhale_proxy.conf diff --git a/deploy/funkwhale_proxy.conf b/deploy/funkwhale_proxy.conf new file mode 100644 index 00000000..1b1dd0d2 --- /dev/null +++ b/deploy/funkwhale_proxy.conf @@ -0,0 +1,13 @@ +# global proxy conf +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_set_header X-Forwarded-Host $host:$server_port; +proxy_set_header X-Forwarded-Port $server_port; +proxy_redirect off; + +# websocket support +proxy_http_version 1.1; +proxy_set_header Upgrade $http_upgrade; +proxy_set_header Connection $connection_upgrade; diff --git a/deploy/nginx.conf b/deploy/nginx.conf index 125fbc6d..1c7b9ae8 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -48,20 +48,6 @@ server { root /srv/funkwhale/front/dist; - # global proxy conf - 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_set_header X-Forwarded-Host $host:$server_port; - proxy_set_header X-Forwarded-Port $server_port; - proxy_redirect off; - - # websocket support - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - location / { try_files $uri $uri/ @rewrites; } @@ -70,6 +56,7 @@ server { rewrite ^(.+)$ /index.html last; } location /api/ { + include /etc/nginx/funkwhale_proxy.conf; # this is needed if you have file import via upload enabled client_max_body_size 30M; proxy_pass http://funkwhale-api/api/; @@ -89,6 +76,7 @@ server { # Transcoding logic and caching location = /transcode-auth { + include /etc/nginx/funkwhale_proxy.conf; # needed so we can authenticate transcode requests, but still # cache the result internal; @@ -97,14 +85,13 @@ server { if ($request_uri ~* "[^\?]+\?(.*)$") { set $query $1; } - proxy_set_header X-Forwarded-Host $host:$server_port; - proxy_set_header X-Forwarded-Port $server_port; proxy_pass http://funkwhale-api/api/v1/trackfiles/viewable/?$query; proxy_pass_request_body off; proxy_set_header Content-Length ""; } location /api/v1/trackfiles/transcode/ { + include /etc/nginx/funkwhale_proxy.conf; # this block deals with authenticating and caching transcoding # requests. Caching is heavily recommended as transcoding # is a CPU intensive process. diff --git a/docs/installation/index.rst b/docs/installation/index.rst index 218049dd..2e62c71e 100644 --- a/docs/installation/index.rst +++ b/docs/installation/index.rst @@ -59,10 +59,11 @@ Ensure you have a recent version of nginx on your server. On debian-like system, apt-get update apt-get install nginx -Then, download our sample virtualhost file: +Then, download our sample virtualhost file and proxy conf: .. parsed-literal:: + curl -L -o /etc/nginx/funkwhale_proxy.conf "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale_proxy.conf" curl -L -o /etc/nginx/sites-enabled/funkwhale.conf "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/nginx.conf" Ensure static assets and proxy pass match your configuration, and check the configuration is valid with ``nginx -t``. If everything is fine, you can restart your nginx server with ``service nginx restart``. -- GitLab