diff --git a/Dockerfile b/Dockerfile index d0efcb2d..a648e769 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ RUN addgroup -S appgroup && adduser -S appuser -G appgroup WORKDIR /app ENV PUBLIC_ADAPTER='docker-node' +ENV VITE_ALLOWED_HOSTS='localhost' COPY . . diff --git a/SELF_HOSTING.md b/SELF_HOSTING.md index 17b0857b..b8d7257f 100644 --- a/SELF_HOSTING.md +++ b/SELF_HOSTING.md @@ -3,6 +3,7 @@ - [Getting started](#getting-started) - [Updating to the latest version](#updating-to-the-latest-version) - [Connecting to an Ollama server hosted elsewhere](#connecting-to-an-ollama-server-hosted-elsewhere) +- [Configuring allowed hosts](#configuring-allowed-hosts) ## Getting started @@ -41,3 +42,15 @@ If you are using the publicly hosted version or your Docker server is on a separ ```bash OLLAMA_ORIGINS=https://hollama.fernando.is ollama serve ``` + +## Configuring allowed hosts + +When hosting Hollama behind a reverse proxy or in a Kubernetes environment, you'll need to specify which domains are allowed to access the application. Use the `VITE_ALLOWED_HOSTS` environment variable to set this: + +```shell +docker run --rm -d -p 4173:4173 \ + -e VITE_ALLOWED_HOSTS='your-domain.com,another-domain.com' \ + --name hollama ghcr.io/fmaclen/hollama:latest +``` + +Multiple domains can be specified by separating them with commas. If not specified, only 'localhost' will be allowed. diff --git a/vite.config.ts b/vite.config.ts index bbf8c7da..22b54c91 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,5 +2,13 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; export default defineConfig({ - plugins: [sveltekit()] + plugins: [sveltekit()], + preview: { + // Allow all hosts in preview mode + host: true, + // Use environment variable for allowed hosts, falling back to localhost + allowedHosts: process.env.VITE_ALLOWED_HOSTS + ? process.env.VITE_ALLOWED_HOSTS.split(',') + : ['localhost'] + } });