bepasty-server icon indicating copy to clipboard operation
bepasty-server copied to clipboard

update docs about socket directory permissions

Open luckman212 opened this issue 3 years ago • 6 comments

I tried to follow the install steps to the best of my ability, on a fresh Ubuntu 21.04 host. I ran into an issue out of the box, where nginx just returns 502 Bad gateway upon accessing the site.

image

In /home/bepasty/logs/nginx-error.log I see something like this:

connect() to unix:/home/bepasty/gunicorn.sock failed (13: Permission denied) while connecting to upstream, client: 10.20.30.x, server: xxxmy.site.name, request: "GET / HTTP/1.1", upstream: "http://unix:/home/bepasty/gunicorn.sock:/", host: "xxxmy.site.name"

I can't figure this out despite lots and lots of googling.

The only thing that "works" for me is to change the user that nginx runs as, by editing /etc/nginx/nginx.conf and changing www-data to bepasty:

user bepasty; #changed from www-data

But, I imagine there are problems with this solution, and it doesn't scale when nginx needs to serve multiple sites.

Has anyone run into this and know how to properly fix? I'm a bit bewildered when it comes to gunicorn/flask.

luckman212 avatar Oct 01 '21 18:10 luckman212

Well, permission denied means you have to fix the permission issue.

So, check the permissions on the socket file and also on all directories above it.

ThomasWaldmann avatar Oct 02 '21 19:10 ThomasWaldmann

Thanks- The .sock file gets owned by the bepasty user. Should it be owned by www-data instead? Or a group?

luckman212 avatar Oct 02 '21 20:10 luckman212

I'ld go via the group (preferably, if you can give it to the nginx group) or others permission (if group can't be done).

ThomasWaldmann avatar Oct 03 '21 11:10 ThomasWaldmann

Ok, the "fix" was to give www-data group permissions on the /home/bepasty dir:

chown bepasty:www-data /home/bepasty

I don't know if this should be in the docs somewhere but it threw me for a loop.

luckman212 avatar Oct 04 '21 13:10 luckman212

A hint would be good, can you make a PR with the docs update?

Guess the xbit on the directory is the minimum requirement. And either adapt the group or give x to others.

ThomasWaldmann avatar Oct 04 '21 14:10 ThomasWaldmann

Sure once I have known-good working steps I am happy to update the docs via a PR. Still working out some issues though!

luckman212 avatar Oct 04 '21 14:10 luckman212