umami.js not reachable
Hey there,
so I installed the app and it's running on apache with node.js on localhost port 4000.
I am redirecting my subdomain umami.example.com to localhost:4000 in htaccess like this:
RewriteCond %{HTTP_HOST} ^umami\.example\.com$ [NC]
RewriteRule ^(.*) http://localhost:4000/$1 [L,P]
I can access the admin interface and I've already added a website, but the site which I wanna track can't access the umami.js script (net::ERR_ABORTED 404 (Not Found)).
Also if I call umami.example.com/umami.js in browser manually the website shows me an "oops! page not found" error.
I've read in Issue #91 that those files/paths /umami.js and /api/collect must have a reverse routing or so, but I don't know how to do that.
I've to mention that I have no access to apache config because it's all running on a managed server from a hosting provider so I can only write into htaccess.. Anybody have an idea how to get that fixed?
I think you need to do something like this, https://httpd.apache.org/docs/2.4/rewrite/proxy.html
I was on that page too and I am already doing a rewriting, see the rewrite condition/rule above, but I guess the /umami.js and /api/collect files need some special treatment.
Is this file only accessable when the app is running or is it like physically lying around somewhere and I can copy it to another path?
I am kinda lost and I need to get that working.
Haven't used Apache in quite a while, but is your virtual host configured correctly? Starting umami spins up a server on your local 3000 port, that port isn't publicly available until you reverse proxy them with Nginx/Apache/Caddy and whatnot. The docs have a snippet for Nginx, your Apache vhost should look something like this.
<VirtualHost *:443>
SSLEngine on
ServerName umami.example.com
// your ssl certs
RewriteEngine On
ProxyPass / http://<SERVER>:3000
RequestHeader set X-Real-IP %{REMOTE_ADDR}s
</VirtualHost>
The umami.js file is sitting in the public folder. But Umami needs to be running and reversed proxied for the /api/collect endpoint.
I appreciate your effort but I have no access to the apache config file where I can edit virtual host, because unfortunately it's a server from a hosting provider..
But let's forget that proxying for a sec, if I type http://localhost:3000 in my browser and I see the admin interface of the app, is the umami.js under http://localhost:3000/umami.js or on another path? And will I still get an "oops! page not found" error or would I see the raw js file?
You should see the raw js file, thats the same URL that the tracking snippet will generate.
Another thing you can do is copy the umami.js file from the public folder and put it on your website. Then in the script add a data-host-url attribute that will send requests to your umami server elsewhere. But you will likely run into the same issue if you don't have a server proxying to umami.
The only two files I see in my public folder is the favicon and the world json file, but not the umami.js.
I can test the connection to the collect URL with test.js right? Any idea why I get an "No id query specified." error?
If you don't see umami.js then the app didn't build correctly. That file is built after you npm run build.
So I cloned the whole repository again and build it. Now I have the umami.js file in the public folder, although I didn't do anything different than the previous time!
The app runs smooth, languages are working fine as well and the best part, proxying works too with the initial two lines in my htaccess file, see my first post.
So data is incoming - issue solved, thanks again!