git clone git@github.com:ollama-webui/ollama-webui.git
pushd ./ollama-webui/
npm run build
Example Caddyfile
Reverse Proxy to localhost:11434
Serve ./build/
# replace localhost with example.com or whateverlocalhost{handle/api/*{reverse_proxylocalhost:11434}file_server{root./build/}}
caddy run --config ./Caddyfile
with Working CORS Snippet
# CORS Preflight (OPTIONS) + Request (GET, POST, PATCH, PUT, DELETE)(cors-api){@match-cors-api-preflightmethodOPTIONShandle@match-cors-api-preflight{header{Access-Control-Allow-Origin"{http.request.header.origin}"Access-Control-Allow-Methods"GET, POST, PUT, PATCH, DELETE, OPTIONS"Access-Control-Allow-Headers"Origin, Accept, Authorization, Content-Type, X-Requested-With"Access-Control-Allow-Credentials"true"Access-Control-Max-Age"3600"defer}respond""204}@match-cors-api-request{not{headerOrigin"{http.request.scheme}://{http.request.host}"}headerOrigin"{http.request.header.origin}"}handle@match-cors-api-request{header{Access-Control-Allow-Origin"{http.request.header.origin}"Access-Control-Allow-Methods"GET, POST, PUT, PATCH, DELETE, OPTIONS"Access-Control-Allow-Headers"Origin, Accept, Authorization, Content-Type, X-Requested-With"Access-Control-Allow-Credentials"true"Access-Control-Max-Age"3600"defer}}}# replace localhost with example.com or whateverlocalhost{## HTTP Basic Auth## (uncomment to enable)# basicauth {# # see .example.env for how to generate tokens# {env.OLLAMA_API_ID} {env.OLLAMA_API_TOKEN_DIGEST}# }handle/api/*{# Comment to disable CORSimportcors-apireverse_proxylocalhost:11434}# Same-Origin Static Web Serverfile_server{root./build/}}
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/10
**Author:** [@coolaj86](https://github.com/coolaj86)
**Created:** 10/21/2023
**Status:** ✅ Merged
**Merged:** 10/22/2023
**Merged by:** [@tjbck](https://github.com/tjbck)
**Base:** `main` ← **Head:** `feat-static`
---
### 📝 Commits (8)
- [`f4f1283`](https://github.com/open-webui/open-webui/commit/f4f1283cd5c1ac461e80d3128c113b64252b6006) feat: enable static builds
- [`86395a8`](https://github.com/open-webui/open-webui/commit/86395a8c1f01c6a7f38a23ad58b6cedcf891522f) feat: enable buildtime API_ENDPOINT env var
- [`b035de1`](https://github.com/open-webui/open-webui/commit/b035de1b869ca4946102d8de8fc14df39ebf78ba) Update node.js.yaml
- [`c307777`](https://github.com/open-webui/open-webui/commit/c307777a6db9f2336882a7034452d3d88d748add) feat: update .env.example and add Caddyfile
- [`859adee`](https://github.com/open-webui/open-webui/commit/859adee36957e09339086684e3957c301d05405c) chore: change to API_ENDPOINT to conventional name API_BASE_URL
- [`87c8467`](https://github.com/open-webui/open-webui/commit/87c8467dd63af404d43d47aaa3339406a8ba7c20) doc: how to build and test static site
- [`6129f41`](https://github.com/open-webui/open-webui/commit/6129f41273bbb9e7fa4de3c76ab4909f906c173f) doc: clarify usage of OLLAMA_API_BASE_URL
- [`f25359f`](https://github.com/open-webui/open-webui/commit/f25359f455a5361956cd65e126b7ce90e5423f4d) doc: contributor added & typo fix
### 📊 Changes
**13 files changed** (+861 additions, -83 deletions)
<details>
<summary>View changed files</summary>
📝 `.github/workflows/node.js.yaml` (+2 -0)
➕ `Caddyfile.localhost` (+64 -0)
📝 `Dockerfile` (+8 -3)
📝 `README.md` (+62 -6)
➕ `example.env` (+8 -0)
📝 `package-lock.json` (+648 -20)
📝 `package.json` (+3 -0)
📝 `run.sh` (+1 -1)
📝 `src/lib/constants.ts` (+18 -6)
➕ `src/routes/+layout.js` (+16 -0)
➖ `src/routes/+page.server.ts` (+0 -30)
📝 `src/routes/+page.svelte` (+25 -15)
📝 `svelte.config.js` (+6 -2)
</details>
### 📄 Description
- switch from `adapter-node` to `adapter-static`
- rename `ENDPOINT` to `API_BASE_URL` to follow common convention and avoid confusing with webserver vs api server
- match on `/api` prefix to more easily allow control of Reverse Proxy routes from Web Server to API Server
# Preview Documentation
https://github.com/coolaj86/ollama-webui/tree/feat-static#how-to-build-for-static-deployment
## How to build
```sh
git clone git@github.com:ollama-webui/ollama-webui.git
pushd ./ollama-webui/
npm run build
```
## Example `Caddyfile`
- Reverse Proxy to `localhost:11434`
- Serve `./build/`
```perl
# replace localhost with example.com or whatever
localhost {
handle /api/* {
reverse_proxy localhost:11434
}
file_server {
root ./build/
}
}
```
```sh
caddy run --config ./Caddyfile
```
### with Working CORS Snippet
```perl
# CORS Preflight (OPTIONS) + Request (GET, POST, PATCH, PUT, DELETE)
(cors-api) {
@match-cors-api-preflight method OPTIONS
handle @match-cors-api-preflight {
header {
Access-Control-Allow-Origin "{http.request.header.origin}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers "Origin, Accept, Authorization, Content-Type, X-Requested-With"
Access-Control-Allow-Credentials "true"
Access-Control-Max-Age "3600"
defer
}
respond "" 204
}
@match-cors-api-request {
not {
header Origin "{http.request.scheme}://{http.request.host}"
}
header Origin "{http.request.header.origin}"
}
handle @match-cors-api-request {
header {
Access-Control-Allow-Origin "{http.request.header.origin}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers "Origin, Accept, Authorization, Content-Type, X-Requested-With"
Access-Control-Allow-Credentials "true"
Access-Control-Max-Age "3600"
defer
}
}
}
# replace localhost with example.com or whatever
localhost {
## HTTP Basic Auth
## (uncomment to enable)
# basicauth {
# # see .example.env for how to generate tokens
# {env.OLLAMA_API_ID} {env.OLLAMA_API_TOKEN_DIGEST}
# }
handle /api/* {
# Comment to disable CORS
import cors-api
reverse_proxy localhost:11434
}
# Same-Origin Static Web Server
file_server {
root ./build/
}
}
```
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/10
Author: @coolaj86
Created: 10/21/2023
Status: ✅ Merged
Merged: 10/22/2023
Merged by: @tjbck
Base:
main← Head:feat-static📝 Commits (8)
f4f1283feat: enable static builds86395a8feat: enable buildtime API_ENDPOINT env varb035de1Update node.js.yamlc307777feat: update .env.example and add Caddyfile859adeechore: change to API_ENDPOINT to conventional name API_BASE_URL87c8467doc: how to build and test static site6129f41doc: clarify usage of OLLAMA_API_BASE_URLf25359fdoc: contributor added & typo fix📊 Changes
13 files changed (+861 additions, -83 deletions)
View changed files
📝
.github/workflows/node.js.yaml(+2 -0)➕
Caddyfile.localhost(+64 -0)📝
Dockerfile(+8 -3)📝
README.md(+62 -6)➕
example.env(+8 -0)📝
package-lock.json(+648 -20)📝
package.json(+3 -0)📝
run.sh(+1 -1)📝
src/lib/constants.ts(+18 -6)➕
src/routes/+layout.js(+16 -0)➖
src/routes/+page.server.ts(+0 -30)📝
src/routes/+page.svelte(+25 -15)📝
svelte.config.js(+6 -2)📄 Description
adapter-nodetoadapter-staticENDPOINTtoAPI_BASE_URLto follow common convention and avoid confusing with webserver vs api server/apiprefix to more easily allow control of Reverse Proxy routes from Web Server to API ServerPreview Documentation
https://github.com/coolaj86/ollama-webui/tree/feat-static#how-to-build-for-static-deployment
How to build
Example
Caddyfilelocalhost:11434./build/with Working CORS Snippet
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.