2024-10-29 14:51:49 +00:00
# Immich Public Proxy
2024-10-29 18:57:44 +00:00
Share your Immich photos and albums in a safe way without exposing your Immich instance to the public.
2024-10-29 15:31:21 +00:00
< p align = "center" width = "100%" >
2024-11-01 13:45:25 +00:00
< img src = "docs/immich.png" width = "180" height = "180" >
2024-10-29 15:31:21 +00:00
< / p >
2024-10-31 13:32:50 +00:00
### Table of Contents
2024-10-31 13:30:26 +00:00
2024-11-01 13:45:25 +00:00
- [Demo <img src="./docs/external-link.png" width="14" height="14"> ](https://immich-demo.note.sx/share/ffSw63qnIYMtpmg0RNvOui0Dpio7BbxsObjvH8YZaobIjIAzl5n7zTX5d6EDHdOYEvo )
2024-10-31 13:31:17 +00:00
- [About this project ](#about-this-project )
2024-10-31 13:30:26 +00:00
- [Install with Docker ](#how-to-install-with-docker )
2024-11-01 05:57:08 +00:00
- [How to use it ](#how-to-use-it )
2024-10-31 13:30:26 +00:00
- [How it works ](#how-it-works )
2024-11-01 14:36:53 +00:00
- [Additional configuration ](#additional-configuration )
2024-10-31 13:30:26 +00:00
- [Feature requests ](#feature-requests )
## About this project
2024-11-01 13:45:25 +00:00
[Immich ](https://github.com/immich-app/immich ) is a wonderful bit of software, but since it holds all your private photos it's best to keep it fully locked down.
2024-10-29 14:51:49 +00:00
This presents a problem when you want to share a photo or a gallery with someone.
2024-10-30 10:25:36 +00:00
**Immich Public Proxy** provides a barrier of security between the public and Immich, and _only_ allows through requests
2024-10-29 14:51:49 +00:00
which you have publicly shared. When it receives a valid request, it talks to Immich locally via API and returns only
those shared images.
2024-11-01 13:45:25 +00:00
It does not require an API key which reduces the attack surface even further. The only things that the proxy
can access are photos that you have made publicly available in Immich. It is stateless and does not know anything
about your Immich instance.
2024-11-01 11:22:38 +00:00
### Features
- Supports sharing photos and videos.
- Supports password-protected shares.
- If sharing a single image, the link will directly open the image file so that you can embed it anywhere you would a normal image.
- All usage happens through Immich - you won't need to touch this app after the initial configuration.
2024-10-29 14:51:49 +00:00
2024-10-31 06:53:56 +00:00
### Why not simply put Immich behind a reverse proxy and only expose the `/share/` path to the public?
To view a shared album in Immich, you need access to the `/api/` path. If you're sharing a gallery with the public, you need
2024-10-31 11:10:47 +00:00
to make that path public. Any existing or future vulnerability has the potential to compromise your Immich instance.
2024-10-31 06:53:56 +00:00
2024-10-31 11:10:47 +00:00
For me, the ideal setup is to have Immich secured privately behind mTLS or VPN, and only allow public access to Immich Public Proxy.
2024-10-31 12:03:33 +00:00
Here is an example setup for [securing Immich behind mTLS ](./docs/securing-immich-with-mtls.md ) using Caddy.
2024-10-29 19:00:41 +00:00
2024-10-30 10:25:36 +00:00
## How to install with Docker
2024-10-29 14:51:49 +00:00
2024-10-31 12:51:06 +00:00
1. Download the [docker-compose.yml ](https://github.com/alangrainger/immich-public-proxy/blob/main/docker-compose.yml ) file.
2024-10-29 14:51:49 +00:00
2024-10-31 13:03:53 +00:00
2. Create a `.env` file to configure the app:
2024-10-29 14:51:49 +00:00
```
IMMICH_URL=http://localhost:2283
2024-10-31 12:51:06 +00:00
PROXY_PUBLIC_URL=https://your-proxy-url.com
2024-10-29 18:57:44 +00:00
PORT=3000
2024-10-29 15:15:34 +00:00
CACHE_AGE=2592000
2024-10-29 14:51:49 +00:00
```
- `IMMICH_URL` is the URL to access Immich in your local network. This is not your public URL.
2024-10-31 12:51:06 +00:00
- `PROXY_PUBLIC_URL` is the public URL for your proxy.
- `PORT` is the external port you want for the docker container.
2024-11-01 05:08:21 +00:00
- `CACHE_AGE` this is setting the Cache-Control header, to tell the visitor's browser to cache the assets. Set to 0 to disable caching. By default this is 30 days.
2024-10-29 14:51:49 +00:00
3. Start the docker container:
```bash
docker-compose up -d
```
2024-10-31 12:51:06 +00:00
4. Set the "External domain" in your Immich **Server Settings** to be the same as the `PROXY_PUBLIC_URL` :
2024-10-29 14:51:49 +00:00
2024-11-01 13:45:25 +00:00
< img src = "docs/server-settings.png" width = "400" height = "182" >
2024-10-29 14:51:49 +00:00
2024-10-30 10:25:36 +00:00
Now whenever you share an image or gallery through Immich, it will automatically create the
2024-10-29 14:51:49 +00:00
correct public path for you.
2024-10-30 10:20:51 +00:00
2024-11-01 05:57:08 +00:00
## How to use it
Other than the initial configuration above, everything else is managed through Immich.
2024-10-30 13:15:14 +00:00
You share your photos/videos as normal through Immich. Because you have set the **External domain** in Immich settings
2024-11-01 13:45:25 +00:00
to be the URL for your proxy app, the links that Immich generates will automaticaly have the correct URL:
2024-11-01 14:36:53 +00:00
< img src = "docs/share-link.webp" width = "751" height = "524" >
2024-10-30 13:15:14 +00:00
2024-11-01 05:57:08 +00:00
## How it works
2024-10-30 13:15:14 +00:00
When the proxy receives a request, it will come as a link like this:
```
https://your-proxy-url.com/share/ffSw63qnIYMtpmg0RNvOui0Dpio7BbxsObjvH8YZaobIjIAzl5n7zTX5d6EDHdOYEvo
```
2024-10-31 06:09:11 +00:00
The part after `/share/` is Immich's shared link public ID (called the `key` [in the docs ](https://immich.app/docs/api/get-my-shared-link )).
2024-10-30 13:15:14 +00:00
2024-10-31 06:53:56 +00:00
**Immich Public Proxy** takes that key and makes an API call to your Immich instance over your local network, to ask what
2024-10-30 13:15:14 +00:00
photos or videos are shared in that share URL.
2024-10-31 06:53:56 +00:00
If it is a valid share URL, the proxy fetches just those assets via local API and returns them to the visitor as an
2024-10-30 13:15:14 +00:00
individual image or gallery.
2024-10-31 06:09:11 +00:00
If the shared link has expired or any of the assets have been put in the Immich trash, it will not return those.
2024-10-30 13:15:14 +00:00
2024-11-01 14:36:53 +00:00
## Additional configuration
2024-10-30 10:20:51 +00:00
2024-11-01 14:36:53 +00:00
The gallery is created using [lightGallery ](https://github.com/sachinchoolur/lightGallery ). You can adjust various settings to customise how your gallery displays.
2024-10-30 10:20:51 +00:00
2024-11-01 14:53:30 +00:00
1. Make a copy of [config.json ](https://github.com/alangrainger/immich-public-proxy/blob/main/config.json ) in the same folder as your `docker-compose.yml` .
2024-10-30 10:20:51 +00:00
2024-11-01 14:36:53 +00:00
2. Pass the config to your docker container by adding a volume like this:
2024-10-30 10:20:51 +00:00
2024-11-01 14:36:53 +00:00
```yaml
volumes:
- ./config.json:/app/config.json:ro
2024-10-30 10:20:51 +00:00
```
2024-11-01 14:36:53 +00:00
3. Restart your container and your custom configuration should be active.
2024-10-30 10:20:51 +00:00
2024-11-01 14:36:53 +00:00
You can find all of lightGallery's settings here:
2024-10-30 10:20:51 +00:00
https://www.lightgalleryjs.com/docs/settings/
2024-10-30 14:31:41 +00:00
2024-11-01 14:53:30 +00:00
For example, to disable the download button for images, you would change `download` to `false` :
2024-11-01 14:36:53 +00:00
```json
{
"lightGallery": {
"controls": true,
"download": false,
"mobileSettings": {
"controls": false,
"showCloseIcon": true,
"download": false
}
}
}
```
2024-10-30 14:31:41 +00:00
## Feature requests
You can [add feature requests here ](https://github.com/alangrainger/immich-public-proxy/discussions/categories/feature-requests?discussions_q=is%3Aopen+category%3A%22Feature+Requests%22+sort%3Atop ),
2024-10-31 06:53:56 +00:00
however my goal with this project is to keep it as lean as possible.
2024-10-30 15:42:34 +00:00
Due to the sensitivity of data contained within Immich, I want anyone with a bit of coding knowledge
to be able to read this codebase and fully understand everything it is doing.