electerious / Ackee

Self-hosted, Node.js based analytics tool for those who care about privacy.
https://ackee.electerious.com
MIT License
4.2k stars 351 forks source link

Add ACKEE_BASEURL configuration. #317

Open dodedodo opened 2 years ago

dodedodo commented 2 years ago

Hey @electerious,

I took a jab at implementing some sort of base URL support. Can you give this a test run and tell me what you think?

I wrote some documentation as well.

Base url

Change the url path at which Ackee listens. You can use this in conjunction with a reverse proxy like nginx or traefik to publish ackee on https://example.com/ackee/ instead of https://ackee.example.com/

ACKEE_BASEURL=/ackee

Do not add a trailing /.

One downside of this implementation is that with ACKEE_BASEURL=/ackee the server listens on example.com/ackee/ , but not at example.com/ackee . This is because the relative paths need the trailing / (at least, I think so. Couldn't get it to work otherwise). It's not a breaking bug, and it's easily solved by configuring a http redirect from /ackee to /ackee/ in your reverse proxy. Maybe we could include that redirect directly in server.js?

The above is now fixed.

vercel[bot] commented 2 years ago

Someone is attempting to deploy a commit to a Personal Account owned by @electerious on Vercel.

@electerious first needs to authorize it.

dodedodo commented 2 years ago

I've added an automatic redirect from /baseurl to /baseurl/. This fixes my initial caveat described above.

I also noticed I forgot to update the healthcheck.js url's.

dodedodo commented 2 years ago

Hello @electerious, have you had time to check my work? If there's anything I can do to get this pull accepted please let me know :+1: .

I also just saw the other pull request for a base URL option (#288). I honestly did not see that before. I'm not trying to step on anyone toes, and I'm sure either of these pulls will do the job just fine 🙂.