-
Notifications
You must be signed in to change notification settings - Fork 816
Support listening on unix socket #4166
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
Conversation
|
Does this work with the mobile apps? |
Yes. does not affect mobile apps. I use both PWA and Android mobile app. |
|
@balki Does the PWA now connect via the socket? Or how you want to use the socket since AFAIK it works only locally. |
Yes. right sockets work locally only. You need a web server like Caddy / Nginx / Apache that connects to audiobookshelf over unix socket. E.g. I have below in my caddy config. audiobookshelf.mydomain.com {
log {
output file /var/log/caddy/audiobookshelf.log
}
header {
Content-Security-Policy "default-src 'self' 'unsafe-inline' data: blob:;"
Referrer-Policy same-origin
}
reverse_proxy unix//run/audiobookshelf/web.sock
}The I use audiobookshelf installed on archlinux: package which uses environment variables for configuration. I have set the environment variable Both PWA and android app, connects to https://audiobookshelf.mydomain.com which is served by caddy web server. They don't know/care that the web server internally connects to audiobookshelf via unix socket. |
|
@advplyr It would be very helpful to have this feature merged soon. I have been patching and manually compiling audiobookshelf for past few releases now to get this support. I run all my selfhosted applications listening via unix sockets so that they can be isolated into dedicated network namespaces. This is a common feature and supported by most self-hosted applications. Few examples:
Also the change is small, straightforward and does not add any new configuration. |
server/Server.js
Outdated
| if(this.Host.startsWith(unixSocketPrefix)) { | ||
| const sockPath = this.Host.slice(unixSocketPrefix.length) | ||
| this.server.listen(sockPath, () => { | ||
| fs.chmodSync(sockPath, 0o666) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this? If that is staying in I think it should be async
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default permissions will depend on user's umask setting. Setting permissions so that the webserver will be able to communicate. This code runs at startup and chmod is fast. Also all other fs functions in this file are not async.
Brief summary
Support listening on unix socket
Which issue is fixed?
Fixes #3819
In-depth Description
When the
HOSToptions/environment variable starts withunix/, rest of it is assumed to be unix socket path.How have you tested this?
Tested in archlinux. see: https://gitea.balki.me/balki-aur/audiobookshelf
Screenshots
N/A