Skip to content

Commit

Permalink
server: lowercase hostname for Host header check (ollama#5851)
Browse files Browse the repository at this point in the history
  • Loading branch information
rick-github authored Dec 10, 2024
1 parent dd42acf commit 757eeac
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1071,11 +1071,13 @@ func isLocalIP(ip netip.Addr) bool {
}

func allowedHost(host string) bool {
host = strings.ToLower(host)

if host == "" || host == "localhost" {
return true
}

if hostname, err := os.Hostname(); err == nil && host == hostname {
if hostname, err := os.Hostname(); err == nil && host == strings.ToLower(hostname) {
return true
}

Expand Down

0 comments on commit 757eeac

Please sign in to comment.