Skip to content

redis pass to unix sockets working? #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
osevan opened this issue Apr 11, 2022 · 11 comments
Open

redis pass to unix sockets working? #69

osevan opened this issue Apr 11, 2022 · 11 comments

Comments

@osevan
Copy link

osevan commented Apr 11, 2022

It is possible to use unix socket in redis pass instead of localhost IP?

Like unix://path/redis.sock?

Thanks and
best regards.

@tzukav
Copy link

tzukav commented Jun 8, 2023

yeah, it is working, I just tested it now.

mkdir /var/run/redis/ && chown -R redis:www-data /var/run/redis

then, in your /etc/redis/redis.conf, search for "unixsocketperm". modify "unixsocket" and "unixsocketperm" as following:
unixsocket /var/run/redis/redis.sock
unixsocketperm 777

then, service redis-server restart.

then, in your nginx configuration, just pass to: unix://var/run/redis/redis.sock

@woutd
Copy link

woutd commented Jan 5, 2024

@tzukav are you sure this is working? This does not seem to work for me at all.

connect() to unix:/... failed (11: Resource temporarily unavailable) while connecting to upstream

I have no trouble connecting to the UNIX socket with redis-cli -s unix:/...

It would be a very nice feature to use UNIX sockets with redis2-nginx-module.

@tzukav
Copy link

tzukav commented Jan 5, 2024

@tzukav are you sure this is working? This does not seem to work for me at all.

connect() to unix:/... failed (11: Resource temporarily unavailable) while connecting to upstream

I have no trouble connecting to the UNIX socket with redis-cli -s unix:/...

It would be a very nice feature to use UNIX sockets with redis2-nginx-module.

can i confirm this is still working.

@tzukav
Copy link

tzukav commented Jan 5, 2024

@woutd is nginx using www-data as user?

@tzukav
Copy link

tzukav commented Jan 5, 2024

"Resource temporarily unavailable" can be a user, permissions error. if the socket file exists, i'm pretty sure there is a user or permission error.

@tzukav
Copy link

tzukav commented Jan 5, 2024

you can try by changing the nginx user to root temporarily, restart nginx and then see if it is working or not

@woutd
Copy link

woutd commented Jan 8, 2024

Thanks for your answer @tzukav.
Sorry, I got it to work from the first time but was also doing some stress tests which caused the "Resource temporarily unavailable" error.

@tzukav
Copy link

tzukav commented Jan 8, 2024

@woutd redis has max connection set by default to something like 10k as i remember. consider increasing ulimit too, the process may be auto killed if something like max open files is hit.

@woutd
Copy link

woutd commented Jan 8, 2024

That is true, I already increased maxclients and max number of open files (ulimit).
The "Resource temporarily unavailable" errors are temporary. Seems to be some "connection build up" limit I am hitting. After a great number of clients are connected everything seems to work.
But this is probably related with Redis, not the NGINX module.
(I was hitting the max number of ephemeral ports using IP, that is why I am looking at UNIX sockets.)

Edit: Increasing tcp-backlog in Redis config resolved my issue.

@tzukav
Copy link

tzukav commented Jan 8, 2024

@woutd yeah, i had same problem with backlog long time ago but in nginx, not redis. backlog is a always a problem in high traffic scenarios. forgot to tell you about it.
also, depending on what you are using redis for, you may want to take a look over https://nginx.org/en/docs/njs/reference.html#dict as a replace for redis non persistent data.

@woutd
Copy link

woutd commented Jan 8, 2024

@tzukav looks nice. Thanks for the info and your support.

I guess this ticket can be closed as UNIX socket support certainly works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants