Skip to content

xlarin/strava-heatmap-envoy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Strava Heatmap Envoy

A simple, lightweight Go proxy server that provides stable access to Strava's global heatmap tiles. It automatically handles the cookie refresh process, and adds the required relaxed CORS headers, making it easy to integrate the heatmap into any web or desktop mapping application.

Overview

This application runs as a server that fetches heatmap tiles from Strava on your behalf. It manages the required cookies and automatically refreshes them when they expire. It serves tiles over standard HTTP and can be configured to server tiles over HTTPS.

The primary goal is to provide a stable tile endpoint, like http://localhost:8080/all/blue/{z}/{x}/{y}.png, which can be used in map clients like Leaflet, OpenLayers, gpx.studio or GIS software like JOSM.

Usage

There are two primary ways to run this application: using Docker or running a pre-compiled binary.

1. Docker

Steps:

  1. Get your personal Strava Session Cookie (Recommended):

    • Log in to the Strava website.
    • Open your browser's developer tools (usually by pressing F12).
    • Go to the "Application" (or "Storage") tab, find the cookies for www.strava.com, and copy the value of the _strava4_session cookie.
  2. Run the container: The image will be pulled automatically from GitHub Container Registry. Replace <your_strava_session_cookie> with the value you copied.

    docker run -d \
      -p 8080:8080 \
      -e STRAVA_SESSION_COOKIE="<your_strava_session_cookie>" \
      --name strava-proxy \
      ghcr.io/lumixen/strava-heatmap-envoy:latest

2. Local Binaries

Pre-compiled binaries for Linux, Windows, and macOS can be found in releases.

Steps:

  1. Download the appropriate binary for your operating system and architecture.

  2. Get your Strava Session Cookie as described in the Docker instructions.

  3. Run the binary from your terminal:

    • Linux / macOS:

      STRAVA_SESSION_COOKIE="<your_strava_session_cookie>" ./strava-heatmap-envoy
    • Windows (Command Prompt):

      set STRAVA_SESSION_COOKIE="<your_strava_session_cookie>"
      strava-heatmap-envoy.exe

Tile Server URL

Once running, you can access the heatmap tiles at the following URL:

http://localhost:8080/{activity}/{color}/{z}/{x}/{y}.png

Example: http://localhost:8080/all/blue/10/512/341.png

A Note on HTTPS and Mixed Content

If you are using these map tiles on a website that is served over https://, you must also serve the tiles either from the localhost or over https://. Modern web browsers block "mixed content" from remote hosts - that is, loading http:// resources on an https:// page - for security reasons.

This proxy can serve tiles over HTTPS if you provide an SSL certificate and a private key.

Enabling HTTPS:

  1. Generate a self-signed certificate: Run the following command to create a certificate valid for e.g. 192.168.1.100.

    openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes -subj "/CN=192.168.1.100"

    This will create cert.pem and key.pem in your current directory.

  2. Run the application with HTTPS enabled: Set the CERT_PEM and KEY_PEM environment variables to the paths of the files you just created.

    • Docker:

      docker run -d \
        -p 8080:8080 \
        -p 8443:8443 \
        -v $(pwd)/cert.pem:/config/cert.pem \
        -v $(pwd)/key.pem:/config/key.pem \
        -e CERT_PEM="/config/cert.pem" \
        -e KEY_PEM="/config/key.pem" \
        -e STRAVA_SESSION_COOKIE="<your_strava_session_cookie>" \
        --name strava-proxy \
        ghcr.io/lumixen/strava-heatmap-envoy:latest
    • Local Binary (Linux/macOS):

      CERT_PEM="cert.pem" KEY_PEM="key.pem" ./strava-heatmap-envoy

Your tile URL will now be available over HTTPS, for example: https://192.168.1.100:8443/all/blue/10/512/341.png. You should accept the risks, obviously.

Upscaling Missing Tiles (Experimental)

This proxy includes an experimental feature to generate tiles for zoom levels that are not natively available from Strava. For example, if you request a tile at zoom level 19 and the highest available tile is at zoom level 15, the proxy will fetch the level 15 tile and upscale it to generate the requested tile.

This is useful for viewing the heatmap at high zoom levels where Strava does not provide data in apps that don't have a good native upscaling mechanism.

To enable this feature, set the ENABLE_SCALING environment variable to 1 or true.

Configuration

The application is configured using environment variables:

Variable Description Default Required
STRAVA_SESSION_COOKIE Your _strava4_session cookie value from strava.com. If not set, a hardcoded fallback is used. No
HTTP_PORT The port for the HTTP server. 8080 No
HTTPS_PORT The port for the HTTPS server. 8443 No
CERT_PEM Path to the SSL certificate file (.pem or .crt). Enables HTTPS if set along with KEY_PEM. No
KEY_PEM Path to the SSL private key file (.pem or .key). Enables HTTPS if set along with CERT_PEM. No
LOG_DEBUG Set to 1 or true to enable verbose logging of served tiles. false No
ENABLE_SCALING Set to 1 or true to enable upscaling of missing tiles from lower zoom levels. false No

Building from Source

To build the project yourself, you need Go installed.

  1. Build a single binary:

    go build .
  2. Build for all target platforms: The scripts/build.sh script cross-compiles binaries for multiple platforms and places them in the build/artifacts directory.

    ./scripts/build.sh

About

A tiny Go app for proxying strava heatmap tile requests

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 85.8%
  • Shell 11.6%
  • Dockerfile 2.6%