Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow requests from specified hosts #271

Merged
merged 2 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 . .

Expand Down
13 changes: 13 additions & 0 deletions SELF_HOSTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
10 changes: 9 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
});
Loading