Setting up litefs with the proxy and docker

I am trying to set up litefs but am facing some confusion after looking at examples and reading the docs, and want to verify my setup with someone more experienced.

  1. in my fly.toml my app is listening on 5019 with ports 80/443 exposed to the world.
  2. In my docker file I previously had 5019 exposed. I think I am now to remove that? And litefs proxy will be the “exposed” port via litefs.yaml?
  3. In litefs.yaml, I think the addr is the lifefs proxy port so I can set it to any port port that does not conflict with something in my fly.toml? Here i hae set it to 8080 for example
  4. target is my app at “localhost:5019”?

Are these settings correct? Thanks.

fly.toml

[[services]]
  internal_port = 5019
  ...
  [[services.ports]]
    handlers = ["http"]
    port = 80
    force_https = true
  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443    

Docker file

...
ENV APPLICATION_PORT=5019
ENV LITEFS_PROXY_PORT=8080
...
# EXPOSE 5019 
ENTRYPOINT ["litefs", "mount"]

litefs.yaml

proxy:
  addr: ":${LITEFS_PROXY_PORT}"  # LiteFS listens on addr and proxies to target
  target: "localhost:${APPLICATION_PORT}"
  db: "${DATABASE_FILENAME}"

Hi… It’s close: this portion of the configuration tells the Fly edge proxy where to send the incoming traffic, and you want that to instead be the LiteFS proxy (which is specified as port 8080 elsewhere).

The chain should be Fly edge proxy → LiteFS proxy → web application.

That way, the LiteFS proxy can intercept writes and redirect them to the primary, etc.

Hope this helps!


listens at tries to contact
Fly edge proxy (public IP) internal_port
LiteFS proxy internal_port
= proxy.addr
proxy.target
web application proxy.target

litefs.yaml

Added litefs, proxy

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.