Piwik Localhost Tracking - matomo

On piwik, I use localhost as a test website. When I type in localhost from my computer, piwik updates its statistics correctly but when another person (co-worker) in the same LAN types in my IP address, it shows the webpage but piwik doesn't update the visits/pageview count. I would like to know why is that? Any help would be appreciated.

You need to add your IP to the trusted_hosts[] configuration. If you installed Piwik under localhost, it will only accept tracking requests if called under that name.
In config.ini.php add:
[General]
trusted_hosts[] = localhost
trusted_hosts[] = 192.168.1.12
Where 192.168.1.12 is your IP address within your LAN:

This config
[General]
trusted_hosts[] = localhost
says on which address you can access Piwik, its admin panel. If you want to track LAN page you have to modify its Tracking code. To get right for you tracking code (it will not work if you have dynamic IP in your network):
add to trusted_hosts IP address you have in LAN
enter Piwik Admin Panel not by localhost but by your LAN address eg. 192.168.1.12
Now all tracking codes will have your IP as server address and will fire requests to your computer where Piwik is installed.
Explaination:
This all happens because when you enter Piwik Admin Panel from your localhost all tracking codes will have localhost as you Piwik address. So if somebody enters webpage with tracking code, browser will try to communicate with user localhost which is: His Computer. and probably he doesn't have your Piwik.

I added these into config.ini.php as #halfdan said.
[General]
trusted_hosts[] = localhost
trusted_hosts[] = 192.168.1.12
Also change (localhost) website URL mapping.
Click on Setting Icon -> Websites -> Manage
Click on desire website Edit Icon (in my case its localhost)
Change URLs fields from localhost to 192.168.1.12

Related

Running localhost react app on mobile phones

I need to connect my react app to my local network by typing in localhost on any device. Im not sure if this is possible. Right now I use my computers IP address and I type the address into my phone browser with port 300 and it works. The only thing is that I am using auth0 and I need a list of callback urls for it to work. Basically anything other than localhost in the url will be blocked. So i need to type in localhost:3000 on my phone and my react app needs to show up.
You can use a service like lvh.me that resolves back to the IP you provide as the subdomains. This will be fairly stable, but you will need to specify the domain to Auth0.
For example, if your IP address is 10.0.0.5 and your app is running on port 3000, from your local network you would visit http://10.0.0.5.lvh.me:3000/ from your phone. This request would resolve to 10.0.0.5:3000.
I am afraid it's not possible. The localhost refers to 127.0.0.1 IP in your computer which is like a globally followed convention for all the devices in the world.
Your router assigns an IP like 167.12.124.12 for each of the devices connected to it and if any other device is connected to the same router, they can communicate with each other by using the IP the router created for the devices.
The router assigned IP won't change unless your device goes offline for some reason. Try adding the IP as an allowed URL in the list of URLs in Auth0.
Make sure both your phone and computer are connected the same wifii. Then, try to figure out how to find your IPv4 Address. The screenshot below shows where to find it on mac, I guess you can find it by typing ipconfig on terminal, too. This IPv4 address is your localhost. I usually run my react app's on port 3000 so when you go to yourIPv4address:3000 on your mobile phone's browser you can see your react app on mobile. Hope it helps. Good luck.

Plesk - http access without domain - using plesk-site-preview forever?

I want to store data for an android app on the server and make in accessable over http for API without having a domain
When I create a "website" in plesk like example.com without registering any domain then I am able to access the data like: IP/plesk-site-preview/example.com/
But the question is can I do it forever? does it has any disadvantages? Is there a "pretier" way than plesk-site-preview? Like IP/example/ for example?
I'm using Plesk Onyx 17.8.11
Thanks in advance
In Plesk, go to Tools & Settings > IP Addresses > click on a public IP address, to which the required domain is assigned in Plesk > select an offline website as a Default site from the drop-down menu.
Now, to access the domain, type in the public IP address chosen above in a web-browser: http://203.0.112.2:80.

Reactjs Script Server not available

"React-scripts", a series of scripts from create-react-app starter pack allows me to use "react-scripts-start" to initialize a server.
Everything works fine, the server turns on and I can access it on localhost:3000 or by using the IP:3000
The problem is when I use other devices from my house. I try to connect to the IP:3000 and it doesn't work. I'm getting "Server not found".
Is it a Windows access problem or am I supposed to set up the server?
I managed to solve my issue. For me, it was not in the firewall, not in the configuration files. Instead, it was the router.
Since I live in UK, I have Hub 3.0 from Virgin Media.
The solution is:
1) Navigate to Connected Devices and copy the IP address for your device. In my case it was xx.xx.0.16/24 so I copied "xx.xx.0.16"
2) Navigate to Advanced Settings > Security > Port Forwarding
3) Click on "Create new Rule". For Local IP will be your IP address, local start port & end port 3000; external start port & end port 3000; Protocol choose both; Enabled on
4) Apply changes
Now here is the trick. When I run the command
npm run start
I'm getting a message which says:
You ca now view your project in the browser:
Local: http://localhost:3000/
On Your Network: http://xx.xx.37.1:3000/
I can navigate to that IP address : 3000 on the hosting laptop however if I want to make other devices access it, I must use the IP address set up in the router which for me is xx.xx.0.16:3000

Apache2 forwarding to an old ddns server

I own a domain for a website (let's just use "X.com"), which for now I'm hosting on my home computer. This domain name points to my dynamic dns (x.ddns.net) name in the web forwarding of the domain name registrar as I have a dynamic ip and I haven't yet found a better way to make sure that the IP is consistently updated.
I recently changed the ddns address (y.ddns.net) and now whenever I try to access my site either from accessing the main domain name (x.com), or via typing in the local lan ip (192.168.1.56) I keep getting forwarded back to my original ddns address (x.ddns.net) and the website won't load.
I've looked through all the settings I can find both locally, with the ddns provider and with the (x.com) registrar to try to pin point where the forward takes place but I'm totally stuck.
Host system is Ubuntu, everything is up-to-date, nothing in /etc/hosts file pointing to the old ddns.
Thanks in advance for any help.
Try DDNS on Cloudflare
Only problem is that you need to move your domain to cloudflare dns servers which is totally free to use.

Not able to access a port on ec2 instance for an Angular app

I am working on an angular app using the angular cli to set things up. Running the ng serve command spawns a server at this address <my_ec2_host_name>:4200. When I try to access the page on the browser it doesn't work (connection timed out error). I believe this is because of security reasons so I added the following rule to my security groups for the ec2 instance:
Port 4200 should now be accessible but I still can't get the page to load. Can someone think of how to get this to work?
Start angular with below command.
ng serve --host=0.0.0.0 --disable-host-check
it will disable host check and allow to access with IP
You can set up the host option like this:
ng serve -host 0.0.0.0
The steps you are doing are correct for opening a port via Security Groups in the EC2 console. Make sure you are modifying the correct security group, and make sure that your changes have been saved.
Your container may have additional firewalls in place, so you will want to check the OS documentation. For Example, RHEL uses iptables as a further security measure: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-IPTables.html.
That looks correct. Are you sure that your server is running and listening for connections?
You should ssh to that server and verify that the page can be loaded locally. Eg:
curl http://<YOUR HOST IP ADDRESS>:4200
eg: curl http://54.164.10.123:4200
You should be careful to use the public ip address (eg: IPv4 Public IP when you're in the EC2 console). I've run into problems in the past where I've got a server listening on one IP address (often localhost) and not the public ip address.
Also maybe a problem: Is your host inside a VPC of some sort?

Resources