beea/open-webui
0
1# Run with2# caddy run --envfile ./example.env --config ./Caddyfile.localhost3#4# This is configured for5# - Automatic HTTPS (even for localhost)6# - Reverse Proxying to Ollama API Base URL (http://localhost:11434/api)7# - CORS8# - HTTP Basic Auth API Tokens (uncomment basicauth section)9 10 11# CORS Preflight (OPTIONS) + Request (GET, POST, PATCH, PUT, DELETE)12(cors-api) {13 @match-cors-api-preflight method OPTIONS14 handle @match-cors-api-preflight {15 header {16 Access-Control-Allow-Origin "{http.request.header.origin}"17 Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"18 Access-Control-Allow-Headers "Origin, Accept, Authorization, Content-Type, X-Requested-With"19 Access-Control-Allow-Credentials "true"20 Access-Control-Max-Age "3600"21 defer22 }23 respond "" 20424 }25 26 @match-cors-api-request {27 not {28 header Origin "{http.request.scheme}://{http.request.host}"29 }30 header Origin "{http.request.header.origin}"31 }32 handle @match-cors-api-request {33 header {34 Access-Control-Allow-Origin "{http.request.header.origin}"35 Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"36 Access-Control-Allow-Headers "Origin, Accept, Authorization, Content-Type, X-Requested-With"37 Access-Control-Allow-Credentials "true"38 Access-Control-Max-Age "3600"39 defer40 }41 }42}43 44# replace localhost with example.com or whatever45localhost {46 ## HTTP Basic Auth47 ## (uncomment to enable)48 # basicauth {49 # # see .example.env for how to generate tokens50 # {env.OLLAMA_API_ID} {env.OLLAMA_API_TOKEN_DIGEST}51 # }52 53 handle /api/* {54 # Comment to disable CORS55 import cors-api56 57 reverse_proxy localhost:1143458 }59 60 # Same-Origin Static Web Server61 file_server {62 root ./build/63 }64}65 