···21212222# Setup
23232424-We are getting close! Testing now
2424+PDS Gatekeeper has 2 parts to its setup, docker compose file and a reverse proxy (Caddy in this case). I will be
2525+assuming you setup the PDS following the directions
2626+found [here](https://atproto.com/guides/self-hosting), but if yours is different, or you have questions, feel free to
2727+let
2828+me know, and we can figure it out.
2929+3030+## Docker compose
3131+3232+The pds gatekeeper container can be found on docker hub under the name `fatfingers23/pds_gatekeeper`. The container does
3333+need access to the `/pds` root folder to access the same db's as your PDS. The part you need to add would look a bit
3434+like below. You can find a full example of what I use for my pds at [./examples/compose.yml](./examples/compose.yml).
3535+This is usually found at `/pds/compose.yaml`on your PDS>
3636+3737+```yml
3838+ gatekeeper:
3939+ container_name: gatekeeper
4040+ image: fatfingers23/pds_gatekeeper:arm-latest
4141+ network_mode: host
4242+ restart: unless-stopped
4343+ #This gives the container to the access to the PDS folder. Source is the location on your server of that directory
4444+ volumes:
4545+ - type: bind
4646+ source: /pds
4747+ target: /pds
4848+ depends_on:
4949+ - pds
5050+```
25512626-Nothing here yet! If you are brave enough to try before full release, let me know and I'll help you set it up.
2727-But I want to run it locally on my own PDS first to test run it a bit.
5252+## Caddy setup
28532929-Example Caddyfile (mostly so I don't lose it for now. Will have a better one in the future)
5454+For the reverse proxy I use caddy. This part is what overwrites the endpoints and proxies them to PDS gatekeeper to add
5555+in extra functionality. The main part is below, for a full example see [./examples/Caddyfile](./examples/Caddyfile).
5656+This is usually found at `/pds/caddy/etc/caddy/Caddyfile` on your PDS.
30573158```caddyfile
3232-http://localhost {
3333-3459 @gatekeeper {
3535- path /xrpc/com.atproto.server.getSession
3636- path /xrpc/com.atproto.server.updateEmail
3737- path /xrpc/com.atproto.server.createSession
3838- path /@atproto/oauth-provider/~api/sign-in
6060+ path /xrpc/com.atproto.server.getSession
6161+ path /xrpc/com.atproto.server.updateEmail
6262+ path /xrpc/com.atproto.server.createSession
6363+ path /@atproto/oauth-provider/~api/sign-in
3964 }
40654166 handle @gatekeeper {
4242- reverse_proxy http://localhost:8080
6767+ reverse_proxy http://localhost:8080
4368 }
44694545- reverse_proxy /* http://localhost:3000
7070+ reverse_proxy http://localhost:3000
7171+```
7272+7373+If you use a cloudflare tunnel then your caddyfile would look a bit more like below with your tunnel proxying to
7474+`localhost:8081` (or w/e port you want).
7575+7676+```caddyfile
7777+http://*.localhost:8082, http://localhost:8082 {
7878+ @gatekeeper {
7979+ path /xrpc/com.atproto.server.getSession
8080+ path /xrpc/com.atproto.server.updateEmail
8181+ path /xrpc/com.atproto.server.createSession
8282+ path /@atproto/oauth-provider/~api/sign-in
8383+ }
8484+8585+ handle @gatekeeper {
8686+ reverse_proxy http://localhost:8080
8787+ }
8888+8989+ reverse_proxy http://localhost:3000
4690}
47914848-```9292+```
9393+9494+# Environment variables and bonuses
9595+9696+Every environment variable can be set in the `pds.env` and shared between PDS and gatekeeper and the PDS, with the
9797+exception of `PDS_ENV_LOCATION`. This can be set to load the pds.env, by default it checks `/pds/pds.env` and is
9898+recommended to mount the `/pds` folder on the server to `/pds` in the pds gatekeeper container.
9999+100100+`PDS_DATA_DIRECTORY` - Root directory of the PDS. Same as the one found in `pds.env` this is how pds gatekeeper knows
101101+knows the rest of the environment variables.
102102+103103+`GATEKEEPER_EMAIL_TEMPLATES_DIRECTORY` - The folder for templates of the emails PDS gatekeeper sends. You can find them
104104+in [./email_templates](./email_templates). You are free to edit them as you please and set this variable to a location
105105+in the pds gateekeper container and it will use them in place of the default ones. Just make sure ot keep the names the
106106+same.
107107+108108+`PDS_BASE_URL` - Base url of the PDS. You most likely want `https://localhost:3000` which is also the default
109109+110110+`GATEKEEPER_HOST` - Host for pds gatekeeper. Defaults to `127.0.0.1`
111111+112112+`GATEKEEPER_PORT` - Port for pds gatekeeper. Defaults to `8080`
+29
examples/Caddyfile
···11+{
22+ email youremail@myemail.com
33+ on_demand_tls {
44+ ask http://localhost:3000/tls-check
55+ }
66+}
77+88+*.yourpds.com, yourpds.com {
99+ tls {
1010+ on_demand
1111+ }
1212+ # You'll most likely just want from here to....
1313+ @gatekeeper {
1414+ path /xrpc/com.atproto.server.getSession
1515+ path /xrpc/com.atproto.server.updateEmail
1616+ path /xrpc/com.atproto.server.createSession
1717+ path /@atproto/oauth-provider/~api/sign-in
1818+ }
1919+2020+ handle @gatekeeper {
2121+ #This is the address for PDS gatekeeper, default is 8080
2222+ reverse_proxy http://localhost:8080
2323+ }
2424+2525+ reverse_proxy http://localhost:3000
2626+ #..here. Copy and paste this replacing the reverse_proxy http://localhost:3000 line
2727+}
2828+2929+
···132132 let sent_from = env::var("PDS_EMAIL_FROM_ADDRESS")
133133 .expect("PDS_EMAIL_FROM_ADDRESS is not set in your pds.env file");
134134135135- //TODO current bug running in docker
136136- // https://github.com/lettre/lettre/issues/349#issuecomment-510155500
137137-138135 let mailer: AsyncSmtpTransport<Tokio1Executor> =
139136 AsyncSmtpTransport::<Tokio1Executor>::from_url(smtp_url.as_str())?.build();
140137 //Email templates setup