Connect through a reverse proxy
HTTPS and Basic Auth in front of TeslaMate API with Caddy or Nginx.
Steps
A reverse proxy puts TeslaMate API behind your own domain with a trusted HTTPS certificate and a username and password. HedgieMate sends the Basic Auth credentials with every request.
Best for: People who already run a reverse proxy, or who have a public IP and a domain.
-
Point a hostname such as teslamate-api.example.com at your server, and forward ports 80 and 443 to the machine that runs the proxy.
-
Create a password hash. With Caddy, run the command shown below. With Nginx, create an htpasswd file.
Caddycaddy hash-password --plaintext 'your-password'
Nginxhtpasswd -c /etc/nginx/.htpasswd hedgiemate
-
Add the site to your proxy configuration using one of the examples below, then reload the proxy.
Caddyfileteslamate-api.example.com { basic_auth { hedgiemate <paste the hash here> } reverse_proxy teslamateapi:8080 }nginx.confserver { listen 443 ssl; server_name teslamate-api.example.com; ssl_certificate /etc/letsencrypt/live/teslamate-api.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/teslamate-api.example.com/privkey.pem; location / { auth_basic "TeslaMate API"; auth_basic_user_file /etc/nginx/.htpasswd; proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; } } -
Open https://teslamate-api.example.com/api/v1/cars in Safari. It should ask for the username and password, then show JSON.
-
In HedgieMate, enter the HTTPS address as the API Endpoint URL, set Authentication Type to Basic Auth, and fill in the same Username and Password.
What to enter in HedgieMate
| Field | Value |
|---|---|
| API Endpoint URL | https://teslamate-api.example.com |
| Authentication Type | Basic Auth |
| Username and Password | The credentials you set on the proxy |
Good to know
- Caddy requests and renews a Let's Encrypt certificate on its own. With Nginx, use Certbot.
- Never publish TeslaMate API over plain HTTP. A trusted Let's Encrypt certificate is better than relying on Allow self-signed certificate.
- If Safari shows 502 or 504, the proxy cannot reach the teslamateapi container. Check the container name and port.
Need Help?
Having trouble with setup? We're here to help you get started.