docs: add mTLS configuration for Traefik
This commit is contained in:
@@ -59,7 +59,7 @@ To view a shared album in Immich, you need access to the `/api/` path. If you're
|
|||||||
to make that path public. Any existing or future vulnerability has the potential to compromise your Immich instance.
|
to make that path public. Any existing or future vulnerability has the potential to compromise your Immich instance.
|
||||||
|
|
||||||
For me, the ideal setup is to have Immich secured privately behind mTLS or VPN, and only allow public access to Immich Public Proxy.
|
For me, the ideal setup is to have Immich secured privately behind mTLS or VPN, and only allow public access to Immich Public Proxy.
|
||||||
Here is an example setup for [securing Immich behind mTLS](./docs/securing-immich-with-mtls.md) using Caddy.
|
Here is an example setup for [securing Immich behind mTLS](./docs/securing-immich-with-mtls.md) using a reverse proxy such as Caddy or Traefik.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,16 @@
|
|||||||
# Securing Immich with mTLS using Caddy
|
# Securing Immich with mTLS using a reverse proxy
|
||||||
|
|
||||||
Immich supports using a custom client certificate on both web and mobile apps, so it's one of the easiest and safest ways to limit access to only clients of your choice.
|
Immich supports using a custom client certificate on both web and mobile apps, so it's one of the easiest and safest ways to limit access to only clients of your choice.
|
||||||
|
|
||||||
## Caddy docker-compose.yml
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
version: "3.7"
|
|
||||||
|
|
||||||
services:
|
|
||||||
caddy:
|
|
||||||
image: caddy:2
|
|
||||||
restart: unless-stopped
|
|
||||||
cap_add:
|
|
||||||
- NET_ADMIN
|
|
||||||
ports:
|
|
||||||
- "6443:443"
|
|
||||||
- "6443:443/udp"
|
|
||||||
volumes:
|
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile:Z
|
|
||||||
- ./site:/srv:Z
|
|
||||||
- ./data:/data:Z
|
|
||||||
- ./config:/config:Z
|
|
||||||
```
|
|
||||||
|
|
||||||
## Authenticating with mutual TLS
|
## Authenticating with mutual TLS
|
||||||
|
|
||||||
|
The process of generating the certificates is the same regardless of which reverse proxy you use. Just make sure to place the folder "certs/" under a volume that is mounted to your reverse proxy container.
|
||||||
|
|
||||||
### Generate your client certificate
|
### Generate your client certificate
|
||||||
|
|
||||||
This is a basic way to generate a certificate for a user. If it's only you using your own homelab, then you'll just need to make one certificate.
|
This is a basic way to generate a certificate for a user. If it's only you using your own homelab, then you'll just need to make one certificate.
|
||||||
|
|
||||||
This certificate will last for ~10 years (although of course you can revoke it at any time by deleting it from Caddy's key store).
|
This certificate will last for ~10 years (although of course you can revoke it at any time by deleting it from your reverse proxy key store).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
@@ -57,7 +38,26 @@ openssl pkcs12 -export -out certs/client.pfx -inkey certs/client.key -in certs/c
|
|||||||
rm certs/client.req
|
rm certs/client.req
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configure Caddyfile
|
## Using Caddy
|
||||||
|
### Caddy docker-compose.yaml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
caddy:
|
||||||
|
image: caddy:2
|
||||||
|
restart: unless-stopped
|
||||||
|
cap_add:
|
||||||
|
- NET_ADMIN
|
||||||
|
ports:
|
||||||
|
- "6443:443"
|
||||||
|
- "6443:443/udp"
|
||||||
|
volumes:
|
||||||
|
- ./Caddyfile:/etc/caddy/Caddyfile:Z
|
||||||
|
- ./site:/srv:Z
|
||||||
|
- ./data:/data:Z
|
||||||
|
- ./config:/config:Z
|
||||||
|
```
|
||||||
|
### Configure Caddyfile
|
||||||
|
|
||||||
```Caddyfile
|
```Caddyfile
|
||||||
https://immich.mydomain.com {
|
https://immich.mydomain.com {
|
||||||
@@ -70,3 +70,55 @@ https://immich.mydomain.com {
|
|||||||
reverse_proxy internal_server.lan:2283
|
reverse_proxy internal_server.lan:2283
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Using Traefik
|
||||||
|
### Traefik docker-compose.yaml
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
traefik:
|
||||||
|
image: traefik:3.5
|
||||||
|
container_name: traefik
|
||||||
|
hostname: traefik
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/Madrid
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
- 443:443
|
||||||
|
volumes:
|
||||||
|
- ./config:/etc/traefik
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configure Traefik dynamic file:
|
||||||
|
```yaml
|
||||||
|
http:
|
||||||
|
services:
|
||||||
|
immich:
|
||||||
|
loadBalancer:
|
||||||
|
servers:
|
||||||
|
- url: "http://immich:2283"
|
||||||
|
|
||||||
|
routers:
|
||||||
|
immich:
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
service: immich
|
||||||
|
rule: "Host(`immich.mydomain.com`)"
|
||||||
|
tls:
|
||||||
|
certResolver: letsencrypt
|
||||||
|
options: mtlsOptions
|
||||||
|
|
||||||
|
tls:
|
||||||
|
options:
|
||||||
|
mtlsOptions:
|
||||||
|
minVersion: VersionTLS12
|
||||||
|
cipherSuites:
|
||||||
|
- TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
|
||||||
|
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
|
||||||
|
- TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
|
||||||
|
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
|
||||||
|
clientAuth:
|
||||||
|
caFiles:
|
||||||
|
- /etc/traefik/certs/client.crt
|
||||||
|
clientAuthType: RequireAndVerifyClientCert
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user