Full VPS IoT Deployment GPS Tracking Backend (VPS + MQTT + Traccar)

Job ID: 40124923

Budget: €100 – €200 EUR

Setup of High-Performance GPS Tracking Backend (VPS + MQTT)
Objective: Configure a VPS to act as a dedicated GPS tracking engine. It must ingest data via EMQX (MQTT), process it using Traccar (for drift filtering and mileage), and expose a secure API for the main website (hosted on Lovebla.dev) to consume.

Architecture Overview
Ingestion: Trackers publish to EMQX (MQTT Broker).

Middleware: A custom Bridge Script (Node.js/Python) subscribes to EMQX and forwards data to Traccar.

Processing: Traccar (running "headless") handles protocol decoding, geofencing, and mileage calculation (filtering GPS drift).

Storage: PostgreSQL stores the high-frequency GPS history locally on the VPS.

Integration: Your Website (Lovebla.dev) calls the Traccar API (via Nginx Reverse Proxy) to fetch vehicle history and current status.

3. Task List for Freelancer
Please complete the following tasks:

Part A: Server Basics & Security
Update OS and configure UFW Firewall.

Open ports: 22 (SSH), 80/443 (Web), 1883/8883 (MQTT).

Block direct access to ports 5432 (Postgres) and 8082 (Traccar UI) from the outside world (allow localhost only).

Install Docker and Docker Compose (Recommended for easy maintenance).

Part B: EMQX (MQTT Broker) Setup
Deploy EMQX (latest stable version).

Configure Authentication: Create a default username/password for trackers to connect.

SSL/TLS: Configure Secure MQTT (Port 8883) using Let's Encrypt certificates so trackers send data securely.

Verification: Ensure trackers can publish JSON to topics like gps/device_id.

Part C: Traccar & Database Setup
Deploy PostgreSQL (v14+) with a dedicated user/database for Traccar.

Deploy Traccar (latest version).

Configuration (traccar.xml):

Connect to PostgreSQL.

CRITICAL: Enable Mileage Calculation & Drift Filtering:

XML

<entry key='coordinates.filter'>true</entry>
<entry key='filter.distance'>20</entry> <entry key='filter.minSpeed'>2</entry> ```

Part D: The "Bridge" (MQTT to Traccar)
Note: Since Traccar does not natively subscribe to generic MQTT topics easily, a bridge is required.

Write a lightweight service (Node.js or Python) running in Docker.

Logic:

Subscribe to EMQX topic gps/+ (or your specific topic).

On message receive: Parse the JSON payload.

Forward data to Traccar via the OsmAnd Protocol (HTTP Request): http://localhost:5055/?id={device_id}&lat={lat}&lon={lon}&timestamp={time}&speed={speed}

Ensure the script auto-restarts on crash (use PM2 or Docker restart: always).

Part E: API Exposure (Nginx)
Install Nginx as a Reverse Proxy.

Point https://gps-api.yourdomain.com to Traccar's API port (8082).

Secure with Let's Encrypt SSL.

CORS Headers: Configure Nginx to allow API requests coming specifically from your website domain (lovela.dev or similar).

4. Deliverables (Acceptance Criteria)
Credentials File: A text file containing:

VPS SSH Root login.

EMQX Dashboard login & MQTT User credentials.

Traccar Admin login.

PostgreSQL Database credentials.

API Endpoint: A working URL (e.g., https://gps.yourdomain.com/api/server) that returns a 200 OK response.

End-to-End Test:

Freelancer must simulate a device sending an MQTT message to EMQX.

Success: The device appears immediately on the Traccar map/dashboard with the correct location.

Documentation: A brief README.md explaining where the "Bridge Script" is located and how to restart it.
Related categories: Python Linux Apache Node.js PostgreSQL Ubuntu MQTT Docker Automation REST API