This article applies to self-built Umami servers.
In the past two days, I added source analysis to the website, and the number of clicks is displayed in the article title. The analysis platform used is Umami.
Docker Compose
Here we use the postgresql version of the image ghcr.io/umami-software/umami:postgresql-latest
|
|
Reverse Proxy
Then use nginx for service reverse proxy (this step is more important, and request filtering will be performed later to solve security issues)
|
|
Now our service is set up, and we can use Cloudflare Tunnel to pass the service to your domain name.
Security Question
But a problem arises. In order for a static website to obtain URL clicks, it is necessary to store the token in the front-end page (or use Cloudflare Worker to circumvent it, which we will not go into here for the time being). How to prevent other users from logging into the management page of the Umami site after obtaining the token?
A simple method is to whitelist the specified URL requests. We count and check the request addresses used, only /script.js
, /api/send
, /api/websites/<id>/stats
, so we filter them in the nginx reverse generation:
|
|
New Problem
This solves our security problem, but we can only log in and view statistics in the intranet environment.
In the next article, we will use Cloudflare Worker to wrap stats requests to completely solve this problem, and no longer limit self-built servers.