1+ # Map routes search queries to the appropriate backend.
2+ # Regex is evaluated once per request; enable ` pcre_jit` for best speed.
13map $arg_q $dest {
2- default google;
3- ~*(?i)^\s*how\s+to\b chatgpt;
4- ~*(?i)^\s*what\s+is\b chatgpt;
5- ~*(?i)^\s*(when| where| why)\b chatgpt;
6- ~*(?i)^\s*who\s+(?:is| was)\b wikipedia;
7- ~*(?i)\bpictures?\s+of\b google_images;
8- ~*(?i)\bvs\b google;
9- ~*(?i)\bdownload\b google;
10- ~*(?i)\bwikipedia\b| \bwiki\b wikipedia;
4+ # direct image search
5+ ~*(?i)\bpictures?\s+of\b google_images;
6+ # map and direction queries
7+ ~*(?i)\b(near\s+me| directions?\s+to| map\s+of)\b google_maps;
8+ # Wikipedia lookups
9+ ~*(?i)\b(?:biography| history| life\s+of)\b wikipedia;
10+ # question detection
11+ ~*(?i)\b(who| what| when| where| why| how| can| could| would| should| do| did| is| are| was| were| am| will| whom| whose| which)\b chatgpt;
12+ # instructional queries
13+ ~*(?i)\b(explain| describe| compare| define )\b chatgpt;
14+ # explicit wiki keywords
15+ ~*(?i)\bwikipedia\b| \bwiki\b wikipedia;
1116{{- range .CustomKeywords }}
1217 ~*(?i)^{{ escape .Phrase }}$ {{ .Dest }};
1318{{- end }}
19+ default google;
1420}
1521
22+ # Map engine names to full URL targets. Update this list in Go.
1623map $dest $target {
17- google " https://www.google.com/search?q=$arg_q" ;
18- google_images " https://www.google.com/search?tbm=isch&q=$arg_q" ;
19- chatgpt " https://chat.openai.com/?q=$arg_q" ;
20- wikipedia " https://en.wikipedia.org/wiki/$arg_q" ;
24+ {{- range $name , $url := .Targets }}
25+ {{ $name }} {{ $url }};
26+ {{- end }}
2127}
2228
2329server {
@@ -28,3 +34,4 @@ server {
2834 return 302 $target ;
2935 }
3036}
37+
0 commit comments