Install help please with HTTP Ras Pi setup


#1

Hi all, thanks for creating this fantastic (looking) tool. I can’t wait to start using it with my music collection, once I get it setup.

I am hoping to make it work as follows: On my local home network only, running on a Ras Pi Model 3B+, with Raspbian 9 Stretch. I want to be able to connect to my Pi from other PCs and phones in my house only.

So far, I’ve followed the Debian install steps (no docker) and that went OK. I am stuck at the steps on how to finish the nginx setup though. I don’t want to get a SSL cert since this is all local.

I’ve seen a few posts like this in here but they all have “Oh, I solved my problem” without specific steps.

I think what I need to do next is switch my .env and my nginx funkwhale.conf files to using HTTP instead of HTTPS. But I am lost and don’t know how to do that.

I also want to make sure I configure nginx to serve the FW site on a port other than 80, as I have a local site running from the same Ras Pi on that port already.

Can someone please provide some specific steps I can follow to do those two things?

Thanks very much,


#2

I should add - when I run ‘nginx -t’ right now, it says:

nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2019/03/23 19:13:53 [warn] 1877#1877: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2019/03/23 19:13:53 [emerg] 1877#1877: duplicate upstream "funkwhale-api" in /etc/nginx/sites-enabled/funkwhale.conf.bak:3
nginx: configuration file /etc/nginx/nginx.conf test failed

Thanks for any help, folks.


#3

Hi @Neb, to have the nginx configuration work on HTTP only, you can use the file below:

# This file was generated from funkwhale.template

upstream funkwhale-api {
    # depending on your setup, you may want to update this
    server ${FUNKWHALE_API_IP}:${FUNKWHALE_API_PORT};
}
# required for websocket support
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen      80;
    listen [::]:80;
    server_name ${FUNKWHALE_HOSTNAME};

   
    root ${FUNKWHALE_FRONTEND_PATH};

    # compression settings
    gzip on;
    gzip_comp_level    5;
    gzip_min_length    256;
    gzip_proxied       any;
    gzip_vary          on;

    gzip_types
        application/javascript
        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 / {
        include /etc/nginx/funkwhale_proxy.conf;
        # this is needed if you have file import via upload enabled
        client_max_body_size ${NGINX_MAX_BODY_SIZE};
        proxy_pass   http://funkwhale-api/;
    }

    location /front/ {
        alias ${FUNKWHALE_FRONTEND_PATH}/;
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

    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/ {
        include /etc/nginx/funkwhale_proxy.conf;
        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/ {
        alias ${MEDIA_ROOT}/;
    }

    location /_protected/media {
        # this is an internal location that is used to serve
        # audio files once correct permission / authentication
        # has been checked on API side
        internal;
        alias   ${MEDIA_ROOT};
    }

    location /_protected/music {
        # this is an internal location that is used to serve
        # audio files once correct permission / authentication
        # has been checked on API side
        # Set this to the same value as your MUSIC_DIRECTORY_PATH setting
        internal;
        alias   ${MUSIC_DIRECTORY_SERVE_PATH};
    }

    location /staticfiles/ {
        # django static files
        alias ${STATIC_ROOT}/;
    }
}

Basically, it has the server listening on port 80 instead of port 443, and removed all SSL related directives.

Your permisison denied issue, however, is different, and probably linked to the fact that you are running nginx as a non root user, meaning the error/access log are not readable by your nginx user. Maybe try a chown www-data -R /var/log/nginx ?


#4

Thank you Eliot. That helped.

I’ve sorted the problem with the permissions (I just needed to start the nginx -t command with sudo. D’oh). And I edited my funkwhale.conf file to match the one you provided for just http.

Now though, I think I’ve completed the setup but when I try to access http://myservermane:8999 (my chosen port #), I see “Server Error (500)”.

I ran the journalctl -xn -u funkwhale-server command it returns:

-- Logs begin at Thu 2016-11-03 11:16:43 MDT, end at Thu 2019-03-28 21:48:00 MDT. --
Mar 28 21:47:34 fifthpi daphne[706]:     return request('get', url, params=params, **kwargs)
Mar 28 21:47:34 fifthpi daphne[706]:   File "/srv/funkwhale/virtualenv/lib/python3.5/site-packages/requests/api.py", line 60, in request
Mar 28 21:47:34 fifthpi daphne[706]:     return session.request(method=method, url=url, **kwargs)
Mar 28 21:47:34 fifthpi daphne[706]:   File "/srv/funkwhale/virtualenv/lib/python3.5/site-packages/requests/sessions.py", line 533, in request
Mar 28 21:47:34 fifthpi daphne[706]:     resp = self.send(prep, **send_kwargs)
Mar 28 21:47:34 fifthpi daphne[706]:   File "/srv/funkwhale/virtualenv/lib/python3.5/site-packages/requests/sessions.py", line 646, in send
Mar 28 21:47:34 fifthpi daphne[706]:     r = adapter.send(request, **kwargs)
Mar 28 21:47:34 fifthpi daphne[706]:   File "/srv/funkwhale/virtualenv/lib/python3.5/site-packages/requests/adapters.py", line 516, in send
Mar 28 21:47:34 fifthpi daphne[706]:     raise ConnectionError(e, request=request)
Mar 28 21:47:34 fifthpi daphne[706]: requests.exceptions.ConnectionError: HTTPConnectionPool(host='funk.local', port=80): Max retries exceeded with url: /front/index.html (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73094570>: Failed to establish a new connection: [Errno -2] Name or service not known',))

I’m not sure why that last line still has port 80 in it but I believe that’s my issue now.

For what it’s worth, I am serving another separate site on port 80 from this same Ras Pi and so I want to run the funkwhale site from port 8999.

Here is my current /etc/nginx/sites-enabled/funkwhale.conf file:

# This file was generated from funkwhale.template

upstream funkwhale-api {
    # depending on your setup, you may want to update this
    server 127.0.0.1:5000;
}

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 8999;
    listen [::]:8999;
    # update this to match your instance name
    server_name funk.local;

    # useful for Let's Encryp
    root /srv/funkwhale/front/dist;

    # compression settings
    gzip on;
    gzip_comp_level    5;
    gzip_min_length    256;
    gzip_proxied       any;
    gzip_vary          on;

    gzip_types
        application/javascript
        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 / {
        include /etc/nginx/funkwhale_proxy.conf;
        # this is needed if you have file import via upload enabled
        client_max_body_size 100M;
        proxy_pass   http://funkwhale-api/;
    }

    location /front/ {
        alias /srv/funkwhale/front/dist/;
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

    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/ {
        include /etc/nginx/funkwhale_proxy.conf;
        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/ {
        alias /srv/funkwhale/data/media/;
    }

    location /_protected/media {
        # this is an internal location that is used to serve
        # audio files once correct permission / authentication
        # has been checked on API side
        internal;
        alias   /srv/funkwhale/data/media;
    }

    location /_protected/music {
        # this is an internal location that is used to serve
        # audio files once correct permission / authentication
        # has been checked on API side
        # Set this to the same value as your MUSIC_DIRECTORY_PATH setting
        internal;
        alias   /srv/funkwhale/data/music;
    }

    location /staticfiles/ {
        # django static files
        alias /srv/funkwhale/data/static/;
    }
}

I tried rebooting my Pi but still get the error 500.

Thanks for any additional ideas.


#5

Can you try this workaround and let me know if it works for you?

https://governance.funkwhale.audio/d/ZPzwBGJl/error-500-when-running-on-rpi-zero-w/1


#6

Did that - thanks again.

So, now, when I try to browse to “funk.local:8999”, I get “Server Error (500)”. The logs show errors with “IsADirectoryError: [Errno 21] Is a directory: ‘/srv/funkwhale/front/dist’”. Not sure why.

But! When I try to browse to “funk.local:8999/front”, I get the app! Hurrah!! And the /api/admin url works now too.

Should I just stick to using that? Or is there anything I can still do for the basic “funklocal:8999” URL?

(Its’ really no big deal to me)

Onward! I will create a new post for any further issues. Thanks much, Eliot.


#7

Oops, there was a mistake in my suggestion, can you try with: FUNKWHALE_SPA_HTML_ROOT=/srv/funkwhale/front/dist/index.html instead?


#8

Cool! That fixed the URL issue. Thanks again.