From c4ca5c144653cb78d4657b5b8fab5ce3c1e102dc Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:44:06 +1200 Subject: [PATCH 1/9] Update OPERATION.md --- Docs/OPERATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/OPERATION.md b/Docs/OPERATION.md index a750a70..356d6c8 100644 --- a/Docs/OPERATION.md +++ b/Docs/OPERATION.md @@ -3,7 +3,7 @@ For using the device once it's been installed ## Standard Behavior ### Tracker -Addition of a GPS tracker to this project is optional. If desired, one can be connected by way of the "Tracker" header on the PCB. If supplied, the tracker will receive power from the external battery at all times, regardless of the car being at home, away, driving or stopped. Generally these trackers are designed to use minimal amounts of power and so cause negligible drain on the external battery. For more information on integrating a tracker with this project, refer to the [TRACKER.md](Tracker) documentation. +Addition of a GPS tracker to this project is optional. If desired, one can be connected by way of the "Tracker" header on the PCB. If supplied, the tracker will receive power from the external battery at all times, regardless of the car being at home, away, driving or stopped. Generally these trackers are designed to use minimal amounts of power and so cause negligible drain on the external battery. For more information on integrating a tracker with this project, refer to the [Tracking](TRACK) documentation. ### 5V Output A switched 5V output is also supplied as part of this project by way of the 2 pin header labelled 5V. This output is supplied from the external battery provided there is something connected to the 5V header. (Note, if using the PCB revision intended for use without an additional battery, this 5V output is supplied by way of a 12V to 5V converter drawing power from the cars own battery). The output to this header is switched on and off in sync with the 12V output to the dash cam. A potential use for this output (and the one I intend to implement) is to power a USB 4G to WiFi dongle. This will ensure that whenever the dash-cam has power, it also has internet connectivity for remote access. From 534b03a8792c60d2bae6204b9b807c86cc38ed4a Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:45:02 +1200 Subject: [PATCH 2/9] Create tracking readme --- Docs/TRACK/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Docs/TRACK/README.md diff --git a/Docs/TRACK/README.md b/Docs/TRACK/README.md new file mode 100644 index 0000000..612e715 --- /dev/null +++ b/Docs/TRACK/README.md @@ -0,0 +1,14 @@ +# Tracking +## Overview +The tracking component actually has very little dependance on this project itself. This project does not provide a means to build any custom tracking hardware, which must be purchased seperately, and the extent of the "integration" this project provides for that hardware is simply to pass through +12V (Const & Acc) and GND. + +If the tracking functionality is all that you are after, there is no requirement to explore the rest of the repository, however, this README article may still provide value. It offers a recommendation for specific off the shelf hardware and open source software, as well as detailed instructions around setting these both up. + +## Guides +* [SERVER](SERVER.md) - for instructions on setting up and configuring the server software +* [HARDWARE](HARDWARE.md) - for hardware recommendation, installation and configuration + +Once the server has been configured, the hardware acquired and the necissary configurations applied to link the two. You should be able to access the Traccar Web UI at any time to monitor the location of the vehicle. + +## Home Assistant +If you use Home Assistant, an integration for the Traccar server can be found [here](https://www.home-assistant.io/integrations/traccar_server/) which will enable you to view the vehicles location on your Home Assistant map. From 792f002599df53d58e302567e3ae8e73648dfc49 Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:45:43 +1200 Subject: [PATCH 3/9] Caps --- Docs/TRACK/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docs/TRACK/README.md b/Docs/TRACK/README.md index 612e715..d5c4263 100644 --- a/Docs/TRACK/README.md +++ b/Docs/TRACK/README.md @@ -5,8 +5,8 @@ The tracking component actually has very little dependance on this project itsel If the tracking functionality is all that you are after, there is no requirement to explore the rest of the repository, however, this README article may still provide value. It offers a recommendation for specific off the shelf hardware and open source software, as well as detailed instructions around setting these both up. ## Guides -* [SERVER](SERVER.md) - for instructions on setting up and configuring the server software -* [HARDWARE](HARDWARE.md) - for hardware recommendation, installation and configuration +* [Server](SERVER.md) - for instructions on setting up and configuring the server software +* [Hardware](HARDWARE.md) - for hardware recommendation, installation and configuration Once the server has been configured, the hardware acquired and the necissary configurations applied to link the two. You should be able to access the Traccar Web UI at any time to monitor the location of the vehicle. From d7a862ec28906c40917164f72076de85bdedcd42 Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:46:18 +1200 Subject: [PATCH 4/9] Added more Tracking docs --- Docs/TRACK/ACCESS.md | 12 +++ Docs/TRACK/FIREWALL.md | 52 +++++++++++ Docs/TRACK/HARDWARE.md | 8 ++ Docs/TRACK/INSTALL.md | 50 +++++++++++ Docs/TRACK/OPTIMIZE.md | 9 ++ Docs/TRACK/SERVER.md | 40 +++++++++ Docs/TRACK/SQL.md | 29 ++++++ Docs/TRACK/SWAP.md | 194 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 394 insertions(+) create mode 100644 Docs/TRACK/ACCESS.md create mode 100644 Docs/TRACK/FIREWALL.md create mode 100644 Docs/TRACK/HARDWARE.md create mode 100644 Docs/TRACK/INSTALL.md create mode 100644 Docs/TRACK/OPTIMIZE.md create mode 100644 Docs/TRACK/SERVER.md create mode 100644 Docs/TRACK/SQL.md create mode 100644 Docs/TRACK/SWAP.md diff --git a/Docs/TRACK/ACCESS.md b/Docs/TRACK/ACCESS.md new file mode 100644 index 0000000..f019ee1 --- /dev/null +++ b/Docs/TRACK/ACCESS.md @@ -0,0 +1,12 @@ +# Access +With the VM stood up in your cloud provider of choice and appropriately firewalled and optimized it's time to access it for the first time. In the case of most cloud providers, a VM will be assigned a static IP (or something similar). + +For Oracle, unless otherwise specified, a VM will receive a public IP which is static for the duration of its life. The IP will persist between reboots of the VM, however if the VM is ever removed entirely, the IP will be unassigned. This should never really present a problem for this purpose as the VM, once stood up, is unlikley to be torn down. + +If desired, one can always purchase a domain name and create a DNS entry that points to this IP. That's optional and outside the scope of this guide, but feel free to look into it if desired. Cloudflare is a powerful and popular provider for these purposes. + +The IP of the VM can be found in its description page, the exact location will vary depending on the service provider you use. For Oracle go to the VMs **Instance Details** page, and then look under heading **Primary VNIC** subheading **Public IPv4 address**. + +Take that IP and paste it into the URL of your web browser with `:8082` appended to it. For example, if the IP was `180.25.113.6` you would enter `180.25.113.6:8082` into your browser. + +This will take you to the Traccar page where you can create an account and sign in. At present you'll have no devices set up. This will be covered next in the hardware set up section. \ No newline at end of file diff --git a/Docs/TRACK/FIREWALL.md b/Docs/TRACK/FIREWALL.md new file mode 100644 index 0000000..96441df --- /dev/null +++ b/Docs/TRACK/FIREWALL.md @@ -0,0 +1,52 @@ +# Firewall +All cloud providers will offer some form of firewalling in order to protect your VPS. This firewall will need to be adjusted to restrict traffic from any unwanted sources/ports and to ensure it doesn't interfere with Traccar traffic. + +There are two steps to this, the first is the firewall within the cloud provider, the second is the firewall on the OS of your VM 9will vary between OS). + +## OCI Firewall +If using OCI (Oracle Cloud Infrastructure), you'll need to take the following steps to configure the firewall correctly. + +Within the Oracle Cloud Web UI vavigate to the detail page for the virtual machine you are interested in. Click on the "Virtual Cloud Network" associated with the VM. + +On the Virtual Cloud Network (VCN) detail page, click on the "Security Lists" link. + +Click on the default security list, assuming you are using that list. + +Click the "Add Ingress Rule" button. + +Enter the details of the new rule and click the "Add Ingress Rules" button. + +The rules to add/modify are below but will need to be modified for your case as follows: +* The port `5030` will vary depending on the tracking hardware you select. These are all listed in the Traccar website or shown on the hardware manufacturers page. 5030 is correct for the hardware recommended in this project. + * This rule is responsible for allowing access to the telemetary port so that Traccar may receive updates from the hardware. The source is set to allow all IPs as most cell providers will not provide a static IP for a 4G device. +* The IP `9.9.9.9/32` for the rule with port `8082` will need to be replaced with the static IP of your home network (if you have one) or changed to `0.0.0.0/0` (allow all) if you do not have a static. + * This rule is responsible for restricting access to the Traccar WebUI. the `/32` suffix specifies that only a that single address should be matched, `/0` along with the `0.0.0.0` address indicates all IPs will be permitted. + * Obviously the "Allow all" option is less restricted from a firewall perspective, so it relies entirely on Traccars built in authentication to control access. +* The IP `9.9.9.9/32` for the rule with port `22` will also need to be replaced with your home static IP if available, or replaced with `0.0.0.0/0` if you do not have one. This is for the same reasons specified above. + * This rule is responsible for controlling access to the SSH port of the VM. It is not necissary to have this rule for day-to-day functionality, so if you prefer to use the in-browser SSH terminal or only open this rule when you are doing config changes, that's perfectly reasonable. + +| Source | Protocol | Source Port Range | Destination Port Range | Type and Code | +| --------------- | -------- | ----------------- | ---------------------- | ------------- | +| 9.9.9.9/32 | TCP | All | 22 | | +| 0.0.0.0/0 | ICMP | | | 3, 4 | +| 10.0.0.0/16 | ICMP | | | 3 | +| 9.9.9.9/32 | TCP | All | 8082 | | +| 0.0.0.0/0 | TCP | All | 5030 | | + +This will sort the firewalling out from the cloud network side. We still need to sort the Ubuntu firewall. + +## VM Firewall +Traditionally Ubuntu hosts use the Uncomplicated Firewall (UFW) as a user-friendly interface to manage the iptables configuration. As explained in the OCI Best Practices documenation page the use of UFW is discouraged because it can lead to serious trouble. UFW is therefore disabled by default. This might catch experienced admins by surprise if they try to open ports via UFW but don’t succeed connecting to the application and cause issues along the way. + +Rather than using UFW, a more direct manipulation of the iptables configuration is necessary. The easiest way to do so is modifying /etc/iptables/rules.v4. The easiest way is to copy the line allowing SSH access and modify the newly copied line to accept traffic for port 8082 and 5030 (again, changing 5030 as needed if your GPS hardware uses a different port)\ +`-A INPUT -p tcp -m state --state NEW -m tcp --dport 8082 -j ACCEPT`\ +`-A INPUT -p tcp -m state --state NEW -m tcp --dport 5030 -j ACCEPT` + +Please ensure the previous line allowing SSH access is still in place or you will be locked out of your system. The line that absolutely has to remain intact reads\ +`-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT` + +Once the rule is added it can be enabled using the following command\ +`$sudo iptables-restore < /etc/iptables/rules.v4` + +Confirm the configuration by running\ +`$ sudo iptables -L INPUT` \ No newline at end of file diff --git a/Docs/TRACK/HARDWARE.md b/Docs/TRACK/HARDWARE.md new file mode 100644 index 0000000..e3b488a --- /dev/null +++ b/Docs/TRACK/HARDWARE.md @@ -0,0 +1,8 @@ +# Hardware + +## Overview + +## Recommended Hardware + +## Initial Configuration + diff --git a/Docs/TRACK/INSTALL.md b/Docs/TRACK/INSTALL.md new file mode 100644 index 0000000..5037841 --- /dev/null +++ b/Docs/TRACK/INSTALL.md @@ -0,0 +1,50 @@ +# Installation +This process has been tested on both Google Cloud and Oracle Cloud Infrastructure (OCI). Both providers offer a free tier with sufficient resources to provision a Traccar Server VM. This guide was written during the OCI deployment, more specifically using an Ubuntu VM server, and so covers that provider and OS more specifically. Some sections will need to be adapted slightly should you choose to use another cloud service provider or operating system. + +This guide will not cover the process of registering for an account, nor provisioning the VM. These are processes that both change regularly, increasing the maintainance requirement of this guide. Plenty of resources exist out there instructing you on how to do both of these tasks with the provider of your choice. + +Return to this guide once your VPS (VM) is spun up on your cloud provider and you have SSH access to it. + +With an Ubuntu VPS set up in your provider of choice, run the below commands to set up the Traccar server. + +Install unzip utility and MySQL server\ +`$ sudo apt update`\ +`$ apt -y install unzip mysql-server` + +Set database password and create a new database, substituting a fresh password where indicated\ +`$ sudo mysql -u root --execute="ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[insert-password-here]'; GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; CREATE DATABASE traccar;"` + +Download the latest installer\ +`$ sudo wget https://www.traccar.org/download/traccar-linux-64-latest.zip` + +Unzip the file and run the installer\ +`$ sudo unzip traccar-linux-*.zip`\ +`$ sudo ./traccar.run` + +Update the configuration file to use MySQL database\ +`$ cd /opt/traccar/conf`\ +`$ sudo nano traccar.xml`\ +Paste in the below, substituting the password where specified: +``` + + + + + + + com.mysql.cj.jdbc.Driver + jdbc:mysql://localhost/traccar?serverTimezone=UTC&allowPublicKeyRetrieval=true&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode='' + root + [db-password-from-before] + + +``` + +Start the Traccar service\ +`$ sudo service traccar start` + +To view the Traccar logs +`$ tail -f /opt/traccar/logs/tracker-server.log` + +To stop the Traccar service\ +`$ sudo service traccar stop` \ No newline at end of file diff --git a/Docs/TRACK/OPTIMIZE.md b/Docs/TRACK/OPTIMIZE.md new file mode 100644 index 0000000..1b5df4d --- /dev/null +++ b/Docs/TRACK/OPTIMIZE.md @@ -0,0 +1,9 @@ +# Optimization for Crash Prevention +The free tier of both Google Cloud and OCI offer machines limited to 1GB of RAM. While this is technically sufficient to host Traccar, in both cases under the default config the system encountered issues with memory exhaustion leading to a total VM crash within 2 days. This could be seen happening in each instance both via the Cloud providers resource monitor and also within the VM by running `htop`. + +As such, additional steps are recommended to optimize performance and provide some additional breathing room. Once implemented, memory consumption drops to approximately 500-600MB and the system remains online for (at the time of writing) indefinitely. + +There are two layers to this. The first is to provide a swap area on your VM for it to offload memory contents to when needed. The second is to disable the performance schema of the SQL database running alongside Traccar. + +1) [SWAP](SWAP.md) - for adding swap to your VM. +2) [SQL](SQL.md) - for disabling the SQL performance schema. \ No newline at end of file diff --git a/Docs/TRACK/SERVER.md b/Docs/TRACK/SERVER.md new file mode 100644 index 0000000..066b402 --- /dev/null +++ b/Docs/TRACK/SERVER.md @@ -0,0 +1,40 @@ +# Server +## Overview +While many tracking software suites exist, the idea here is to avoid any kind of commercial offering which incur either large up-front costs or monthly subscriptions or require expensive propitary hardware. It is also important to avoid going too far in the other direction and getting some cheap device from the local hobby store which will drain the battery in a day and offer limited functionality and integration. + +One great option is [Traccar](https://www.traccar.org/). This software is open source, free to use, has been around since 2009, and supports more than 2,000 different models of GPS hardware. It also supports integration with Home Assistant if that's important to you. + +There are three main components to the Traccar software suite, the server, the manager and the client. + +* Traccar Server is the main software which include the back-end for device communication and the front-end web interface for managing the GPS tracking devices. + +* Traccar Manager is a mobile based front end application which can be used to manage GPS tracking devices. + +* Traccar Client is a mobile based application which acts as an alternative to GPS tracking hardware and can be used to report the mobile phone's location to the Traccar Server. + +As this document is targeted towards a use-case involving dedicated hardware, it will skip over the Traccar Client. The Manager is also outside the scope of this document as, while it may be used with this installation, it is not required. The Traccar server offers a basic Web UI in which the user can view their devices, by integration with Home Assistant, the devices can be surfaced in there too. + +## Hosting Options +Traccar does offer the option to pay them a monthly fee to make use of hosting service they provide. You can pay a reduced fee for your own account on a shared server, with a relatively small device limit (starting at "up to 5 devices"). This is the most basic and reliable option, it is also fairly reasonably priced. If you don't mind paying the subscription cost, it's not a bad option. Targeted more towards commercial customers with fleet tracking needs is the option to pay a higher fee for your own dedicated server, the starting tier in this case is "up to 50 devices". In the case of this project however, while the account offering is tempting, the use case here is only tracking a single vehicle, not 5, and as Traccar is good enough to offer their software open source for anyone to use, with a bit of extra work, a free solution can be devised. + +Another option would be to self-host on a server at home, assuming you have a static IP. The issue with this is that it does require opening up a hole in ones home firewall and forwarding a specific port to the Traccar machine. This is fairly unavoidable as the tracking hardware **needs** to communicate with the server, and it **needs** a port open to do this. GPS hardware is usually fairly basic so there's no option of having it connect to a self hosted VPN or anything like that. In truth, the Traccar software is pretty robust, exposing a port to it for receiving GPS telemetary is unlikely to present any real security risk, so by all means pursue this if you wish. Firewall rules and/or VLANs can further isolate the Traccar server in the event it is compromised. If that option doesn't appeal to you, you don't have a machine for 24/7 self hosting, or you don't have a static IP, there is an additional option which takes the advantages of the ones already explored with none of the compromises. + +Rather than hosting the server within ones own network, and thus punching a hole in their firewall, these days it's easier than ever to spin up a VM instance on a cloud provider such as, Azure, AWS, Google Cloud, or Oracle Cloud Infrastrucre. Many of these providers offer a free teir with limited resources in which you won't get charged for your use. Fortunately, these resources are still plenty to run a very lightweight Traccar instance making it ideal for this use case. They are also available with static IPs, making them ideal for both access by the user and also for the GPS tracker to reach out to. Finally, they present no compromises to ones home network security or need for any kind of in-house hosting hardware. It is this option that the remainder of this document focuses on. + +## Guides +Follow these in the order specified below. +1) [INSTALL](INSTALL.md) - for the installation of the software within the VM. +2) [FIREWALL](FIREWALL.md) - for the configuration of the firewall both on the cloud provider and within the VM. +3) [OPTIMIZE](OPTIMIZE.md) - for the optimization required to ensure the VM doesn't crash within a few days. +4) [ACCESS](ACCESS.md) - for instructions on accessing Traccar Web UI. + +## Useful resources +These resources are the source of much of the processes and fixes documented above. Refer to them for further information and to give credit to the original authors. +* Installation: + * [VPS Installation](https://www.traccar.org/install-digitalocean/) +* Firewalling: + * [OCI & VM](https://blogs.oracle.com/developers/post/enabling-network-traffic-to-ubuntu-images-in-oracle-cloud-infrastructure) + * [OCI (With images)](https://oracle-base.com/articles/vm/oracle-cloud-infrastructure-oci-amend-firewall-rules) +* Optimization: + * [Swap File](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04) + * [SQL]() \ No newline at end of file diff --git a/Docs/TRACK/SQL.md b/Docs/TRACK/SQL.md new file mode 100644 index 0000000..1d00c13 --- /dev/null +++ b/Docs/TRACK/SQL.md @@ -0,0 +1,29 @@ +# SQL Optimization +## Optimization +Traccar uses a MySQL instance for storing its data. SQL can be quite memory hungry and given our 1GB of RAM limitations, we need to trim it down. This can be performed very easily by disabling its `performance_schema`. + +## What is the Performance Schema? +The answer to that is pretty well covered in [this](https://stackoverflow.com/questions/75337059/what-does-mysqls-performance-schema-do-and-what-are-the-ramifications-of-disabl) Stack Overflow article. However, to summarize the responses: + +The Performance Schema is for monitoring and instrumenting the MySQL Server. Many types of monitoring tools may depend on it. In saying that, disabling performance schema is perfectly fine and will save you some of that memory. + +To say that you're compromising something is misleading. It's left on by default because it can be useful and in most cases people can spare the memory, but like any tool you only need it if you're going to use it. If you're not going to use it, you're absolutely free to turn it off with no negative impact at all. + +In a corporate or high-stakes environment, monitoring is an important tool. However, a small VM that you run for a personal project is exactly the kind of use case where you would want to turn it off. + +## Disabling the Schema +Run the following commands: + +`$ sudo nano /etc/mysql/my.cnf` + +At the bottom of the file, add the following:\ +``` +[mysqld] +performance_schema = off +``` + +Exit, saving changes. + +Restart the VM to ensure the changes are applied successfully. + +Use the command `htop` to view current system resource utilization, it should have dropped significantly. Some users report drops from 400MB to 25MB, others indicate a drop of 350MB to 130MB. The amount of memory saved by disabling this feature will vary from installation to installation depending on the amount of RAM available and the size of the SQL database. However, in the case of the Traccar server, it has resulted in overall memory use being down to about 500MB. \ No newline at end of file diff --git a/Docs/TRACK/SWAP.md b/Docs/TRACK/SWAP.md new file mode 100644 index 0000000..9359a96 --- /dev/null +++ b/Docs/TRACK/SWAP.md @@ -0,0 +1,194 @@ +# Swap Optimization +*The below documentation has been lifted in its entierty from a [Digital Ocean tutorial](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04). All credit goes to the original author [Brian Boucheron](https://www.digitalocean.com/community/users/bboucheron).* + +*It is included here for the purposes of consolidating this Traccar tutorial all in one place.* + +## What is Swap? +Swap is a portion of hard drive storage that has been set aside for the operating system to temporarily store data that it can no longer hold in RAM. This lets you increase the amount of information that your server can keep in its working memory, with some caveats. The swap space on the hard drive will be used mainly when there is no longer sufficient space in RAM to hold in-use application data. + +The information written to disk will be significantly slower than information kept in RAM, but the operating system will prefer to keep running application data in memory and use swap for the older data. Overall, having swap space as a fallback for when your system’s RAM is depleted can be a good safety net against out-of-memory exceptions on systems with non-SSD storage available. + +## Step 1 – Checking the System for Swap Information + +Before we begin, we can check if the system already has some swap space available. It is possible to have multiple swap files or swap partitions, but generally one should be enough. We can see if the system has any configured swap by typing:\ +`$ sudo swapon --show` + +If you don’t get back any output, this means your system does not have swap space available currently. You can verify that there is no active swap using the free utility:\ +`$ free -h` +``` +Output + total used free shared buff/cache available +Mem: 981Mi 122Mi 647Mi 0.0Ki 211Mi 714Mi +Swap: 0B 0B 0B +``` +As you can see in the Swap row of the output, no swap is active on the system. + +## Step 2 – Checking Available Space on the Hard Drive Partition + +Before we create our swap file, we’ll check our current disk usage to make sure we have enough space. Do this by entering:\ +`$ df -h` + +``` +Output +Filesystem Size Used Avail Use% Mounted on +udev 474M 0 474M 0% /dev +tmpfs 99M 932K 98M 1% /run +/dev/vda1 25G 1.4G 23G 7% / +tmpfs 491M 0 491M 0% /dev/shm +tmpfs 5.0M 0 5.0M 0% /run/lock +tmpfs 491M 0 491M 0% /sys/fs/cgroup +/dev/vda15 105M 3.9M 101M 4% /boot/efi +/dev/loop0 55M 55M 0 100% /snap/core18/1705 +/dev/loop1 69M 69M 0 100% /snap/lxd/14804 +/dev/loop2 28M 28M 0 100% /snap/snapd/7264 +tmpfs 99M 0 99M 0% /run/user/1000 +``` + +The device with `/` in the `Mounted on` column is our disk in this case. We have plenty of space available in this example (only 1.4G used). Your usage will probably be different. + +Although there are many opinions about the appropriate size of a swap space, it really depends on your personal preferences and your application requirements. Generally, an amount equal to or double the amount of RAM on your system is a good starting point. Another good rule of thumb is that anything over 4G of swap is probably unnecessary if you are just using it as a RAM fallback. + +## Step 3 – Creating a Swap File + +Now that we know our available hard drive space, we can create a swap file on our filesystem. We will allocate a file of the size that we want called `swapfile` in our root (`/`) directory. + +The best way of creating a swap file is with the `fallocate` program. This command instantly creates a file of the specified size. + +Since the server in our example has 1G of RAM, we will create a 1G file in this guide. Adjust this to meet the needs of your own server:\ +`$ sudo fallocate -l 1G /swapfile` + +We can verify that the correct amount of space was reserved by typing:\ +`$ ls -lh /swapfile`\ +Which returns: +``` +-rw-r--r-- 1 root root 1.0G Apr 25 11:14 /swapfile +``` +Our file has been created with the correct amount of space set aside. + +## Step 4 – Enabling the Swap File + +Now that we have a file of the correct size available, we need to actually turn this into swap space. + +First, we need to lock down the permissions of the file so that only users with root privileges can read the contents. This prevents normal users from being able to access the file, which would have significant security implications. + +Make the file only accessible to root by typing:\ +`$ sudo chmod 600 /swapfile` + +Verify the permissions change by typing:\ +`$ ls -lh /swapfile`\ +Which outputs: +``` +-rw------- 1 root root 1.0G Apr 25 11:14 /swapfile +``` + +As you can see, only the root user has the read and write flags enabled. + +We can now mark the file as swap space by typing:\ +`$ sudo mkswap /swapfile`\ +Which outputs: +``` +Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) +no label, UUID=6e965805-2ab9-450f-aed6-577e74089dbf +``` + +After marking the file, we can enable the swap file, allowing our system to start using it:\ +`$ sudo swapon /swapfile` + +Verify that the swap is available by typing:\ +`$ sudo swapon --show`\ +Output: +``` +NAME TYPE SIZE USED PRIO +/swapfile file 1024M 0B -2 +``` + +We can check the output of the `free` utility again to corroborate our findings:\ +`$ free -h`\ +Output: +``` + total used free shared buff/cache available +Mem: 981Mi 123Mi 644Mi 0.0Ki 213Mi 714Mi +Swap: 1.0Gi 0B 1.0Gi +``` + +Our swap has been set up successfully and our operating system will begin to use it as necessary. + +## Step 5 – Making the Swap File Permanent + +Our recent changes have enabled the swap file for the current session. However, if we reboot, the server will not retain the swap settings automatically. We can change this by adding the swap file to our `/etc/fstab` file. + +Back up the `/etc/fstab` file in case anything goes wrong:\ +`$ sudo cp /etc/fstab /etc/fstab.bak` + +Add the swap file information to the end of your /etc/fstab file by typing:\ +`$ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab` + +Next we’ll review some settings we can update to tune our swap space. + +## Step 6 – Tuning your Swap Settings + +There are a few options that you can configure that will have an impact on your system’s performance when dealing with swap. + +### Adjusting the Swappiness Property +The `swappiness` parameter configures how often your system swaps data out of RAM to the swap space. This is a value between 0 and 100 that represents a percentage. + +With values close to zero, the kernel will not swap data to the disk unless absolutely necessary. Remember, interactions with the swap file are “expensive” in that they take a lot longer than interactions with RAM and they can cause a significant reduction in performance. Telling the system not to rely on the swap much will generally make your system faster. + +Values that are closer to 100 will try to put more data into swap in an effort to keep more RAM space free. Depending on your applications’ memory profile or what you are using your server for, this might be better in some cases. + +We can see the current swappiness value by typing:\ +`$ cat /proc/sys/vm/swappiness`\ +Output: +``` +60 +``` + +For a Desktop, a swappiness setting of 60 is not a bad value. For a server, you might want to move it closer to 0. + +We can set the swappiness to a different value by using the `sysctl` command. + +*Note here from WMTaylor3, not part of the original article. I went for a setting of 30 in order to ensure our 1GB of memory wouldn't cause us to crash out.*\ +For instance, to set the swappiness to 10, we could type:\ +`$ sudo sysctl vm.swappiness=10`\ +Output: +``` +vm.swappiness = 10 +``` + +This setting will persist until the next reboot. We can set this value automatically at restart by adding the line to our /etc/sysctl.conf file:\ +`$ sudo nano /etc/sysctl.conf` + +At the bottom, you can add:\ +`vm.swappiness=10` + +Save and close the file when you are finished. + +### Adjusting the Cache Pressure Setting +Another related value that you might want to modify is the `vfs_cache_pressure`. This setting configures how much the system will choose to cache inode and dentry information over other data. + +Basically, this is access data about the filesystem. This is generally very costly to look up and very frequently requested, so it’s an excellent thing for your system to cache. You can see the current value by querying the `proc` filesystem again:\ +`$ cat /proc/sys/vm/vfs_cache_pressure`\ +Output: +``` +100 +``` + +As it is currently configured, our system removes inode information from the cache too quickly. We can set this to a more conservative setting like 50 by typing:\ +`$ sudo sysctl vm.vfs_cache_pressure=50`\ +Output: +``` +vm.vfs_cache_pressure = 50 +``` + +Again, this is only valid for our current session. We can change that by adding it to our configuration file like we did with our swappiness setting:\ +`$ sudo nano /etc/sysctl.conf` + +At the bottom, add the line that specifies your new value:\ +`vm.vfs_cache_pressure=50` + +Save and close the file when you are finished. + +## Conclusion +Following the steps in this guide will give you some breathing room in cases that would otherwise lead to out-of-memory exceptions. Swap space can be incredibly useful in avoiding some of these common problems. + +If you are running into OOM (out of memory) errors, or if you find that your system is unable to use the applications you need, the best solution is to optimize your application configurations or upgrade your server. \ No newline at end of file From 040c65a9a884105f983d0c2f8b06ecca64904115 Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:47:19 +1200 Subject: [PATCH 5/9] Update main README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b3882ce..0288f63 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ If you want to modify or contribute to the project, this is the place to start. * [Code](Code) - for anything related to the Arduino code running on the ESP32. +* [Tracking](Docs/TRACK) - for anything related to the GPS tracking accessory aspect. + * [Installation](Installation) - for anything related to the installation of the finished product. * [Operation](Docs/OPERATION.md) - for use of the installed product. From 6dcf1c8ce2509190640bd1d4426d4b86bfbe2692 Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:47:46 +1200 Subject: [PATCH 6/9] Caps --- Docs/TRACK/SERVER.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Docs/TRACK/SERVER.md b/Docs/TRACK/SERVER.md index 066b402..6dc2c6b 100644 --- a/Docs/TRACK/SERVER.md +++ b/Docs/TRACK/SERVER.md @@ -23,10 +23,10 @@ Rather than hosting the server within ones own network, and thus punching a hole ## Guides Follow these in the order specified below. -1) [INSTALL](INSTALL.md) - for the installation of the software within the VM. -2) [FIREWALL](FIREWALL.md) - for the configuration of the firewall both on the cloud provider and within the VM. -3) [OPTIMIZE](OPTIMIZE.md) - for the optimization required to ensure the VM doesn't crash within a few days. -4) [ACCESS](ACCESS.md) - for instructions on accessing Traccar Web UI. +1) [Install](INSTALL.md) - for the installation of the software within the VM. +2) [Firewall](FIREWALL.md) - for the configuration of the firewall both on the cloud provider and within the VM. +3) [Optimize](OPTIMIZE.md) - for the optimization required to ensure the VM doesn't crash within a few days. +4) [Access](ACCESS.md) - for instructions on accessing Traccar Web UI. ## Useful resources These resources are the source of much of the processes and fixes documented above. Refer to them for further information and to give credit to the original authors. @@ -37,4 +37,4 @@ These resources are the source of much of the processes and fixes documented abo * [OCI (With images)](https://oracle-base.com/articles/vm/oracle-cloud-infrastructure-oci-amend-firewall-rules) * Optimization: * [Swap File](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04) - * [SQL]() \ No newline at end of file + * [SQL]() From 5440b37077df81dcb3f8649925ec79d9f36c97e4 Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:53:00 +1200 Subject: [PATCH 7/9] Update SERVER.md --- Docs/TRACK/SERVER.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/TRACK/SERVER.md b/Docs/TRACK/SERVER.md index 6dc2c6b..ac3ce03 100644 --- a/Docs/TRACK/SERVER.md +++ b/Docs/TRACK/SERVER.md @@ -34,7 +34,7 @@ These resources are the source of much of the processes and fixes documented abo * [VPS Installation](https://www.traccar.org/install-digitalocean/) * Firewalling: * [OCI & VM](https://blogs.oracle.com/developers/post/enabling-network-traffic-to-ubuntu-images-in-oracle-cloud-infrastructure) - * [OCI (With images)](https://oracle-base.com/articles/vm/oracle-cloud-infrastructure-oci-amend-firewall-rules) + * [OCI (with images)](https://oracle-base.com/articles/vm/oracle-cloud-infrastructure-oci-amend-firewall-rules) * Optimization: * [Swap File](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04) * [SQL]() From 819277388b3db88ec47c3afd3b1ea3cc8d24c7de Mon Sep 17 00:00:00 2001 From: William Taylor <40162687+WMTaylor3@users.noreply.github.com> Date: Fri, 9 Aug 2024 17:53:17 +1200 Subject: [PATCH 8/9] caps --- Docs/TRACK/OPTIMIZE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docs/TRACK/OPTIMIZE.md b/Docs/TRACK/OPTIMIZE.md index 1b5df4d..7db630c 100644 --- a/Docs/TRACK/OPTIMIZE.md +++ b/Docs/TRACK/OPTIMIZE.md @@ -5,5 +5,5 @@ As such, additional steps are recommended to optimize performance and provide so There are two layers to this. The first is to provide a swap area on your VM for it to offload memory contents to when needed. The second is to disable the performance schema of the SQL database running alongside Traccar. -1) [SWAP](SWAP.md) - for adding swap to your VM. -2) [SQL](SQL.md) - for disabling the SQL performance schema. \ No newline at end of file +1) [Swap](SWAP.md) - for adding swap to your VM. +2) [SQL](SQL.md) - for disabling the SQL performance schema. From 0b571b91b7ccb3569be370bae74ee3877ef98c1a Mon Sep 17 00:00:00 2001 From: William Taylor Date: Sun, 11 Aug 2024 16:00:48 +1200 Subject: [PATCH 9/9] Spell checking and formatting --- Docs/TRACK/ACCESS.md | 4 ++-- Docs/TRACK/FIREWALL.md | 20 +++++++++++++------- Docs/TRACK/INSTALL.md | 2 +- Docs/TRACK/OPTIMIZE.md | 1 + Docs/TRACK/README.md | 5 +++-- Docs/TRACK/SERVER.md | 11 ++++++++--- 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Docs/TRACK/ACCESS.md b/Docs/TRACK/ACCESS.md index f019ee1..7892cb0 100644 --- a/Docs/TRACK/ACCESS.md +++ b/Docs/TRACK/ACCESS.md @@ -1,7 +1,7 @@ # Access -With the VM stood up in your cloud provider of choice and appropriately firewalled and optimized it's time to access it for the first time. In the case of most cloud providers, a VM will be assigned a static IP (or something similar). +With the VM stood up in your cloud provider of choice and appropriately firewalled and optimized it's time to access it for the first time. In the case of most cloud providers, a VM will be assigned a static IP (or something similar). -For Oracle, unless otherwise specified, a VM will receive a public IP which is static for the duration of its life. The IP will persist between reboots of the VM, however if the VM is ever removed entirely, the IP will be unassigned. This should never really present a problem for this purpose as the VM, once stood up, is unlikley to be torn down. +For Oracle, unless otherwise specified, a VM will receive a public IP which is static for the duration of its life. The IP will persist between reboots of the VM, however if the VM is ever removed entirely, the IP will be unassigned. This should never really present a problem for this purpose as the VM, once stood up, is unlikely to be torn down. If desired, one can always purchase a domain name and create a DNS entry that points to this IP. That's optional and outside the scope of this guide, but feel free to look into it if desired. Cloudflare is a powerful and popular provider for these purposes. diff --git a/Docs/TRACK/FIREWALL.md b/Docs/TRACK/FIREWALL.md index 96441df..365a9b6 100644 --- a/Docs/TRACK/FIREWALL.md +++ b/Docs/TRACK/FIREWALL.md @@ -6,7 +6,7 @@ There are two steps to this, the first is the firewall within the cloud provider ## OCI Firewall If using OCI (Oracle Cloud Infrastructure), you'll need to take the following steps to configure the firewall correctly. -Within the Oracle Cloud Web UI vavigate to the detail page for the virtual machine you are interested in. Click on the "Virtual Cloud Network" associated with the VM. +Within the Oracle Cloud Web UI navigate to the detail page for the virtual machine you are interested in. Click on the "Virtual Cloud Network" associated with the VM. On the Virtual Cloud Network (VCN) detail page, click on the "Security Lists" link. @@ -18,12 +18,18 @@ Enter the details of the new rule and click the "Add Ingress Rules" button. The rules to add/modify are below but will need to be modified for your case as follows: * The port `5030` will vary depending on the tracking hardware you select. These are all listed in the Traccar website or shown on the hardware manufacturers page. 5030 is correct for the hardware recommended in this project. - * This rule is responsible for allowing access to the telemetary port so that Traccar may receive updates from the hardware. The source is set to allow all IPs as most cell providers will not provide a static IP for a 4G device. + +* This rule is responsible for allowing access to the telemetry port so that Traccar may receive updates from the hardware. The source is set to allow all IPs as most cell providers will not provide a static IP for a 4G device. + * The IP `9.9.9.9/32` for the rule with port `8082` will need to be replaced with the static IP of your home network (if you have one) or changed to `0.0.0.0/0` (allow all) if you do not have a static. - * This rule is responsible for restricting access to the Traccar WebUI. the `/32` suffix specifies that only a that single address should be matched, `/0` along with the `0.0.0.0` address indicates all IPs will be permitted. - * Obviously the "Allow all" option is less restricted from a firewall perspective, so it relies entirely on Traccars built in authentication to control access. + +* This rule is responsible for restricting access to the Traccar Web UI. the `/32` suffix specifies that only a that single address should be matched, `/0` along with the `0.0.0.0` address indicates all IPs will be permitted. + +* Obviously the "Allow all" option is less restricted from a firewall perspective, so it relies entirely on Traccars built in authentication to control access. + * The IP `9.9.9.9/32` for the rule with port `22` will also need to be replaced with your home static IP if available, or replaced with `0.0.0.0/0` if you do not have one. This is for the same reasons specified above. - * This rule is responsible for controlling access to the SSH port of the VM. It is not necissary to have this rule for day-to-day functionality, so if you prefer to use the in-browser SSH terminal or only open this rule when you are doing config changes, that's perfectly reasonable. + +* This rule is responsible for controlling access to the SSH port of the VM. It is not necessary to have this rule for day-to-day functionality, so if you prefer to use the in-browser SSH terminal or only open this rule when you are doing config changes, that's perfectly reasonable. | Source | Protocol | Source Port Range | Destination Port Range | Type and Code | | --------------- | -------- | ----------------- | ---------------------- | ------------- | @@ -31,12 +37,12 @@ The rules to add/modify are below but will need to be modified for your case as | 0.0.0.0/0 | ICMP | | | 3, 4 | | 10.0.0.0/16 | ICMP | | | 3 | | 9.9.9.9/32 | TCP | All | 8082 | | -| 0.0.0.0/0 | TCP | All | 5030 | | +| 0.0.0.0/0 | TCP | All | 5030 | | This will sort the firewalling out from the cloud network side. We still need to sort the Ubuntu firewall. ## VM Firewall -Traditionally Ubuntu hosts use the Uncomplicated Firewall (UFW) as a user-friendly interface to manage the iptables configuration. As explained in the OCI Best Practices documenation page the use of UFW is discouraged because it can lead to serious trouble. UFW is therefore disabled by default. This might catch experienced admins by surprise if they try to open ports via UFW but don’t succeed connecting to the application and cause issues along the way. +Traditionally Ubuntu hosts use the Uncomplicated Firewall (UFW) as a user-friendly interface to manage the iptables configuration. As explained in the OCI Best Practices documentation page the use of UFW is discouraged because it can lead to serious trouble. UFW is therefore disabled by default. This might catch experienced admins by surprise if they try to open ports via UFW but don’t succeed connecting to the application and cause issues along the way. Rather than using UFW, a more direct manipulation of the iptables configuration is necessary. The easiest way to do so is modifying /etc/iptables/rules.v4. The easiest way is to copy the line allowing SSH access and modify the newly copied line to accept traffic for port 8082 and 5030 (again, changing 5030 as needed if your GPS hardware uses a different port)\ `-A INPUT -p tcp -m state --state NEW -m tcp --dport 8082 -j ACCEPT`\ diff --git a/Docs/TRACK/INSTALL.md b/Docs/TRACK/INSTALL.md index 5037841..08c32cf 100644 --- a/Docs/TRACK/INSTALL.md +++ b/Docs/TRACK/INSTALL.md @@ -1,7 +1,7 @@ # Installation This process has been tested on both Google Cloud and Oracle Cloud Infrastructure (OCI). Both providers offer a free tier with sufficient resources to provision a Traccar Server VM. This guide was written during the OCI deployment, more specifically using an Ubuntu VM server, and so covers that provider and OS more specifically. Some sections will need to be adapted slightly should you choose to use another cloud service provider or operating system. -This guide will not cover the process of registering for an account, nor provisioning the VM. These are processes that both change regularly, increasing the maintainance requirement of this guide. Plenty of resources exist out there instructing you on how to do both of these tasks with the provider of your choice. +This guide will not cover the process of registering for an account, nor provisioning the VM. These are processes that both change regularly, increasing the maintenance requirement of this guide. Plenty of resources exist out there instructing you on how to do both of these tasks with the provider of your choice. Return to this guide once your VPS (VM) is spun up on your cloud provider and you have SSH access to it. diff --git a/Docs/TRACK/OPTIMIZE.md b/Docs/TRACK/OPTIMIZE.md index 7db630c..39aab95 100644 --- a/Docs/TRACK/OPTIMIZE.md +++ b/Docs/TRACK/OPTIMIZE.md @@ -6,4 +6,5 @@ As such, additional steps are recommended to optimize performance and provide so There are two layers to this. The first is to provide a swap area on your VM for it to offload memory contents to when needed. The second is to disable the performance schema of the SQL database running alongside Traccar. 1) [Swap](SWAP.md) - for adding swap to your VM. + 2) [SQL](SQL.md) - for disabling the SQL performance schema. diff --git a/Docs/TRACK/README.md b/Docs/TRACK/README.md index d5c4263..da42fd5 100644 --- a/Docs/TRACK/README.md +++ b/Docs/TRACK/README.md @@ -1,14 +1,15 @@ # Tracking ## Overview -The tracking component actually has very little dependance on this project itself. This project does not provide a means to build any custom tracking hardware, which must be purchased seperately, and the extent of the "integration" this project provides for that hardware is simply to pass through +12V (Const & Acc) and GND. +The tracking component actually has very little dependence on this project itself. This project does not provide a means to build any custom tracking hardware, which must be purchased separately, and the extent of the "integration" this project provides for that hardware is simply to pass through +12V (Const & Acc) and GND. If the tracking functionality is all that you are after, there is no requirement to explore the rest of the repository, however, this README article may still provide value. It offers a recommendation for specific off the shelf hardware and open source software, as well as detailed instructions around setting these both up. ## Guides * [Server](SERVER.md) - for instructions on setting up and configuring the server software + * [Hardware](HARDWARE.md) - for hardware recommendation, installation and configuration -Once the server has been configured, the hardware acquired and the necissary configurations applied to link the two. You should be able to access the Traccar Web UI at any time to monitor the location of the vehicle. +Once the server has been configured, the hardware acquired and the necessary configurations applied to link the two. You should be able to access the Traccar Web UI at any time to monitor the location of the vehicle. ## Home Assistant If you use Home Assistant, an integration for the Traccar server can be found [here](https://www.home-assistant.io/integrations/traccar_server/) which will enable you to view the vehicles location on your Home Assistant map. diff --git a/Docs/TRACK/SERVER.md b/Docs/TRACK/SERVER.md index ac3ce03..f86303f 100644 --- a/Docs/TRACK/SERVER.md +++ b/Docs/TRACK/SERVER.md @@ -1,6 +1,6 @@ # Server ## Overview -While many tracking software suites exist, the idea here is to avoid any kind of commercial offering which incur either large up-front costs or monthly subscriptions or require expensive propitary hardware. It is also important to avoid going too far in the other direction and getting some cheap device from the local hobby store which will drain the battery in a day and offer limited functionality and integration. +While many tracking software suites exist, the idea here is to avoid any kind of commercial offering which incur either large up-front costs or monthly subscriptions or require expensive proprietar hardware. It is also important to avoid going too far in the other direction and getting some cheap device from the local hobby store which will drain the battery in a day and offer limited functionality and integration. One great option is [Traccar](https://www.traccar.org/). This software is open source, free to use, has been around since 2009, and supports more than 2,000 different models of GPS hardware. It also supports integration with Home Assistant if that's important to you. @@ -17,24 +17,29 @@ As this document is targeted towards a use-case involving dedicated hardware, it ## Hosting Options Traccar does offer the option to pay them a monthly fee to make use of hosting service they provide. You can pay a reduced fee for your own account on a shared server, with a relatively small device limit (starting at "up to 5 devices"). This is the most basic and reliable option, it is also fairly reasonably priced. If you don't mind paying the subscription cost, it's not a bad option. Targeted more towards commercial customers with fleet tracking needs is the option to pay a higher fee for your own dedicated server, the starting tier in this case is "up to 50 devices". In the case of this project however, while the account offering is tempting, the use case here is only tracking a single vehicle, not 5, and as Traccar is good enough to offer their software open source for anyone to use, with a bit of extra work, a free solution can be devised. -Another option would be to self-host on a server at home, assuming you have a static IP. The issue with this is that it does require opening up a hole in ones home firewall and forwarding a specific port to the Traccar machine. This is fairly unavoidable as the tracking hardware **needs** to communicate with the server, and it **needs** a port open to do this. GPS hardware is usually fairly basic so there's no option of having it connect to a self hosted VPN or anything like that. In truth, the Traccar software is pretty robust, exposing a port to it for receiving GPS telemetary is unlikely to present any real security risk, so by all means pursue this if you wish. Firewall rules and/or VLANs can further isolate the Traccar server in the event it is compromised. If that option doesn't appeal to you, you don't have a machine for 24/7 self hosting, or you don't have a static IP, there is an additional option which takes the advantages of the ones already explored with none of the compromises. +Another option would be to self-host on a server at home, assuming you have a static IP. The issue with this is that it does require opening up a hole in ones home firewall and forwarding a specific port to the Traccar machine. This is fairly unavoidable as the tracking hardware **needs** to communicate with the server, and it **needs** a port open to do this. GPS hardware is usually fairly basic so there's no option of having it connect to a self hosted VPN or anything like that. In truth, the Traccar software is pretty robust, exposing a port to it for receiving GPS telemetry is unlikely to present any real security risk, so by all means pursue this if you wish. Firewall rules and/or VLANs can further isolate the Traccar server in the event it is compromised. If that option doesn't appeal to you, you don't have a machine for 24/7 self hosting, or you don't have a static IP, there is an additional option which takes the advantages of the ones already explored with none of the compromises. -Rather than hosting the server within ones own network, and thus punching a hole in their firewall, these days it's easier than ever to spin up a VM instance on a cloud provider such as, Azure, AWS, Google Cloud, or Oracle Cloud Infrastrucre. Many of these providers offer a free teir with limited resources in which you won't get charged for your use. Fortunately, these resources are still plenty to run a very lightweight Traccar instance making it ideal for this use case. They are also available with static IPs, making them ideal for both access by the user and also for the GPS tracker to reach out to. Finally, they present no compromises to ones home network security or need for any kind of in-house hosting hardware. It is this option that the remainder of this document focuses on. +Rather than hosting the server within ones own network, and thus punching a hole in their firewall, these days it's easier than ever to spin up a VM instance on a cloud provider such as, Azure, AWS, Google Cloud, or Oracle Cloud Infrastructure. Many of these providers offer a free tier with limited resources in which you won't get charged for your use. Fortunately, these resources are still plenty to run a very lightweight Traccar instance making it ideal for this use case. They are also available with static IPs, making them ideal for both access by the user and also for the GPS tracker to reach out to. Finally, they present no compromises to ones home network security or need for any kind of in-house hosting hardware. It is this option that the remainder of this document focuses on. ## Guides Follow these in the order specified below. 1) [Install](INSTALL.md) - for the installation of the software within the VM. + 2) [Firewall](FIREWALL.md) - for the configuration of the firewall both on the cloud provider and within the VM. + 3) [Optimize](OPTIMIZE.md) - for the optimization required to ensure the VM doesn't crash within a few days. + 4) [Access](ACCESS.md) - for instructions on accessing Traccar Web UI. ## Useful resources These resources are the source of much of the processes and fixes documented above. Refer to them for further information and to give credit to the original authors. * Installation: * [VPS Installation](https://www.traccar.org/install-digitalocean/) + * Firewalling: * [OCI & VM](https://blogs.oracle.com/developers/post/enabling-network-traffic-to-ubuntu-images-in-oracle-cloud-infrastructure) * [OCI (with images)](https://oracle-base.com/articles/vm/oracle-cloud-infrastructure-oci-amend-firewall-rules) + * Optimization: * [Swap File](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04) * [SQL]()