Skip to content
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

Configure the server to listen on a unix socket #237

Closed
gustavgenberg opened this issue Nov 5, 2019 · 9 comments · Fixed by #621
Closed

Configure the server to listen on a unix socket #237

gustavgenberg opened this issue Nov 5, 2019 · 9 comments · Fixed by #621
Labels
a:feature New feature or request

Comments

@gustavgenberg
Copy link

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
A way of configuring the server to listen on a unix socket.
For example you could join the listenaddr and the port into a
single option called listen. Then the listen option could either
get passed localhost:1234 or unix:/tmp/gotify.sock.

Describe alternatives you've considered
n/a

Additional context
n/a

@gustavgenberg gustavgenberg added the a:feature New feature or request label Nov 5, 2019
@jmattheis
Copy link
Member

Do you have a specific use-case for this? This would be a breaking change which would require manual intervention of the user.

@gustavgenberg
Copy link
Author

I am currently running many different applications behind an nginx reverse proxy. By having the applications listen on a unix socket, I do not have to deal with a ton of different ports (aswell as there is a tiny performance gain). Therefore using the same structure for Gotify makes sense to me.

Maybe the listen option could override the listenaddr and port options, thus making the update backwards-compatible.

@sik0vny
Copy link

sik0vny commented May 5, 2020

I would also like that for cleaner connection with nginx

@schneidersoft
Copy link

I also have this situation. I use nginx to handle ssh stuff and reverse proxy gotify.

@jerrykan
Copy link

jerrykan commented Jun 1, 2021

I'd also be happy if this was implemented. When running multiple applications behind a reverse proxy it is often much nicer to be able to proxy to a unix socket instead of having to pick a random port and hope some other service doesn't try to start listening on the same port. Using a socket like unix:/run/gotify/gotify.sock is much more unique that say port 8080

@LaurenceJJones
Copy link
Contributor

Hey all 👋🏻

I thought I just drop my use case in here if it helps as I know the issue been open a long time.

I am Gotify within a Docker container and want to make sure that the networks are separated on the Host. So currently I am attaching the a gotify container to all networks to allow container within the network to push messages. However, an easier way could be to create a unix socket and then mount that as a volume within each container than the TCP overhead will be removed.

Thanks for reading the general idea, I am wiling to look into implementing this, however, cause the issue age I would like to know if the maintainer would want it 👍🏻

@jmattheis
Copy link
Member

@LaurenceJJones Yes, contributions for this are welcome. I'd say we make this configurable via server.listenaddr and server.ssl.listenaddr. If the value starts with unix: then a socket will be created. E.g.

server:
  keepaliveperiodseconds: 0 # 0 = use Go default (15s); -1 = disable keepalive; set the interval in which keepalive packets will be sent. Only change this value if you know what you are doing.
  listenaddr: "unix:/var/run/gotify-server.sock"
  # ... 

@LaurenceJJones
Copy link
Contributor

Thank you for responding fast and with the idea of the implementation you would like to see. Since implementing this I would like to know if #554 is also on the cards, as using a unix socket without this option your logs have empty remote IP

2024-01-16T07:52:15Z | 200 |     304.232µs |                 | GET      "/"
2024-01-16T07:52:15Z | 200 |    9.572077ms |                 | GET      "/static/css/2.0f3898ba.chunk.css"
2024-01-16T07:52:15Z | 200 |   10.613353ms |                 | GET      "/static/js/main.b292f66c.chunk.js"
2024-01-16T07:52:15Z | 200 |   31.441821ms |                 | GET      "/static/js/2.f78cef81.chunk.js"
2024-01-16T07:52:15Z | 200 |    4.012945ms |                 | GET      "/current/user"
2024-01-16T07:52:15Z | 200 |      47.044µs |                 | GET      "/static/media/roboto-latin-400.176f8f5b.woff2"
2024-01-16T07:52:15Z | 200 |      27.858µs |                 | GET      "/static/media/roboto-latin-500.f5b74d7f.woff2"
2024-01-16T07:52:15Z | 200 |      50.595µs |                 | GET      "/static/favicon-196x196.png"
2024-01-16T07:52:15Z | 200 |      13.177µs |                 | GET      "/static/favicon-16x16.png"
2024-01-16T07:52:15Z | 200 |     160.358µs |                 | GET      "/stream?token=[masked]"
2024-01-16T07:52:15Z | 200 |     304.638µs |                 | GET      "/application"
2024-01-16T07:52:15Z | 200 |     332.621µs |                 | GET      "/message?since=0"

Gin has a way to set trusted IPs and which headers and I believe this modifies it already for the logger. Lets me know and I can work on this whilst you PR the former?

@jmattheis
Copy link
Member

Yeah, you can work on it. A setting with trusted ips sounds fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature New feature or request
Development

Successfully merging a pull request may close this issue.

6 participants