Optional: Self-hosting sql-over-http for Docker Compose

We publish our sql-over-http images to a private repository on Docker Hub

You can create your own (free) account at https://hub.docker.com/ and send us the Docker ID for that account. Alternatively, if you already have an appropriate account, you can send your Docker ID to support@tines.com

We'll then grant your user access to the appropriate repositories.

Here's an example of using docker-compose to quickly get the service up and running:

**> ls**
docker-compose.yml your-ssl-cert.crt  your-ssl-cert.key

**> cat docker-compose.yml**
version: "2.2"
services:
  sql-over-http:
    container_name: sql-over-http
    image: tines/sql-over-http:latest
    volumes:
      - ./your-ssl-cert.crt:/ssl/tls.crt
      - ./your-ssl-cert.key:/ssl/tls.key
    ports:
      - "80:80"
      - "443:443"
    environment:
      API_KEY: "your-secret-api-key"
      DISABLE_POSTGRESQL_QUERIES: "false"

**> docker login**
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: your-docker-id
Password:
Login Succeeded

**> docker-compose pull**
Pulling sql-over-http ... done

**> docker-compose up -d**
Starting sql-over-http ... done

**> curl --insecure -X POST \
    -H "X-API-Key: your-secret-api-key" \
    -H "Content-Type: application/json" \
    https://localhost/postgresql/query \
    -d '{"your": "request here"}'**

The docker-compose.yml file:

version: "2.2"
services:
  sql-over-http:
    container_name: sql-over-http
    image: tines/sql-over-http:latest
    volumes:
      - ./your-ssl-cert.crt:/ssl/tls.crt
      - ./your-ssl-cert.key:/ssl/tls.key
    ports:
      - "80:80"
      - "443:443"
    environment:
      API_KEY: "your-secret-api-key"
      DISABLE_POSTGRESQL_QUERIES: "false"

You will need to separately get your own .crt and .key files for a SSL cert corresponding to the hostname you'll be be making sql-over-http available from.

You can disable queries to Postgres databases by setting the DISABLE_POSTGRESQL_QUERIES enviromnent variable to "true"

Here's a simple one liner to generate an insecure self-signed cert for quick testing:

openssl req -x509 -out your-ssl-cert.crt -keyout your-ssl-cert.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Was this helpful?