etesync / server

The Etebase server (so you can run your own)
https://www.etesync.com
GNU Affero General Public License v3.0
1.54k stars 75 forks source link

Server doesn't see files in /static/ #98

Closed johentsch closed 3 years ago

johentsch commented 3 years ago

Hey folks,

Thanks for this great project, I'm excited to set up my own etebase on a Raspberry 3 B+ running 5.10.36-1-MANJARO-ARM! Followed the docs for setting it up running on port 8001 and managed to connect via the etesync app on my google-free phone.

The issue is that the app server doesn't seem to see the static path specified in the config file. It keeps logging errors such as

INFO:     192.168.178.xxx:51968 - "GET /static/admin/css/responsive.css HTTP/1.1" 404 Not Found
INFO:     192.168.178.xxx:51978 - "GET /static/admin/js/prepopulate_init.js HTTP/1.1" 404 Not Found
INFO:     192.168.178.xxx:51976 - "GET /static/admin/js/change_form.js HTTP/1.1" 404 Not Found
INFO:     192.168.178.xxx:51974 - "GET /static/admin/img/icon-addlink.svg HTTP/1.1" 404 Not Found

meaning that the admin page works but looks very black and white. However, the requested files are in the static folder which has read permissions for everyone. The entry in my etebase_nginx.conf reads

location /static/ {
        alias /home/user/etebase/static/ ; # Project's static files
    }

Any idea what could be the trouble? Let me know if you need more info.

Thanks and cheers!

tasn commented 3 years ago

You need to run collectstatic. See: https://github.com/etesync/server/wiki/Production-setup-using-Nginx#setup-nginx

johentsch commented 3 years ago

As stated in the issue I had followed the guide, which also includes the execution of collectstatic. Restating what is written above, the "not found" files are present under the correct paths assuming that /static/ is replaced by the path specified in the conf file. The issue is not solved.

tasn commented 3 years ago

Ah, I see the problem, the alias is wrong, it should not contain the trailing static/. Also, you probably want to use root rather than alias, so:

    root         /home/user/etebase;
    location /static/ {
        alias /home/user/etebase/static/ ; # Project's static files
    }

Or for extra safety:

    root         /home/user/etebase/www-data;
    location /static/ {
        try_files $uri $uri/ =404;
    }

and put all of the files in www-data

johentsch commented 3 years ago

Thanks for the support.

I've now tried the first solution with and without including the trailing static/ in the alias. Also tried the second one, the folder www-data had not existed before. Both attempts did not solve the issue. Is it sufficient to restart nginx and uvicorn after the changes or is there anything else I need to do?

tasn commented 3 years ago

Can you please come to https://www.etesync.com/community-chat/ and ask there? It's a local configuration issue. You are doing something wrong, and it would be much easier to debug it with real-time chat. We can improve the docs afterwards.

No need to restart uvicorn, just need to restart nginx if changing the nginx config. The most likely issue is that your data is not there (so collectstatic is populating the wrong place). As I said in my comment, www-data is a new name I suggeseted, it didn't already exist.

johentsch commented 3 years ago

This is the current version of the config file (needed to change extension): etebase_nginx.conf.txt

tasn commented 3 years ago

ls /home/hentsche/etebase/www-data

johentsch commented 3 years ago

admin

tasn commented 3 years ago

OK, so do this: Change the nginx config from root /home/hentsche/etebase/www-data; to root /home/hentsche/etebase/; and restart nginx. It should now work.

One more thing is to verify that nginx has access to this directory (in case it dosen't work).

johentsch commented 3 years ago

Unfortunately, nothing changed. I've also asked in the chat and we tried with copying static to /tmp/static and made the user http (which runs the nginx worker) the owner. By now I have tried so many constellations that I start doubting nginx is caring at all about what I write in the config file.

tasn commented 3 years ago

It's 99.999% you doing something wrong and we just haven't figured out what. You'd probably be more lucky trying to chat with the nginx community. Anyhow, I'm closing this ticket as it's really not an issue with the server. We have many instances using nginx, and things work as expected.