Skip to content

Instantly share code, notes, and snippets.

@lukas2511
Last active December 21, 2017 13:49
Show Gist options
  • Save lukas2511/518f04742d1cc902f27277118bf43475 to your computer and use it in GitHub Desktop.
Save lukas2511/518f04742d1cc902f27277118bf43475 to your computer and use it in GitHub Desktop.
server {
listen 443 ssl http2 proxy_protocol;
listen [::]:443 ssl http2 proxy_protocol;
ssl_certificate /etc/dehydrated/certs/search.kurz.pw/fullchain.pem;
ssl_certificate_key /etc/dehydrated/certs/search.kurz.pw/privkey.pem;
server_name search.kurz.pw;
access_log off;
error_log off;
location ~^/opensearch.xml {
return 200 '<?xml version="1.0" encoding="UTF-8" ?><OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"><Url type="application/opensearchdescription+xml" rel="self" template="https://${host}/opensearch.xml" /><ShortName>${host}</ShortName><Description>${host}</Description><Image width="16" height="16">data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMS41IDMxLjUiPjxwYXRoIHN0eWxlPSJmaWxsOiMwMDAwMDA7IiBkPSJNMy40LDMuNGMtNC41LDQuNS00LjUsMTEuOCwwLDE2LjNjNC4yLDQuMiwxMC45LDQuNSwxNS40LDAuOGwxMSwxMWwxLjctMS43bC0xMS0xMWMzLjctNC41LDMuNC0xMS4yLTAuOC0xNS40QzE1LjItMS4xLDcuOS0xLjEsMy40LDMuNHpNMTguMSwxOGMtMy42LDMuNi05LjUsMy42LTEzLjEsMEMxLjQsMTQuNCwxLjQsOC41LDUsNC45YzMuNi0zLjYsOS41LTMuNiwxMy4xLDBDMjEuNyw4LjUsMjEuNywxNC40LDE4LjEsMTh6Ii8+PC9zdmc+Cg==</Image><InputEncoding>UTF-8</InputEncoding><Url type="text/html" template="https://${host}/{searchTerms}"/></OpenSearchDescription>';
types { application/opensearchdescription+xml xml; }
}
location "~^/\!([^ ]*)\+(.*)$" { return 302 "/!$1 $2"; }
location ~^/\!gi\ (.+)$ { return 302 "https://www.google.de/search?tbm=isch&q=$1+-site:pinterest.*"; }
location ~^/\!g\ (.+)$ { return 302 https://www.google.de/search?q=$1; }
location ~^/\!yt\ (.+)$ { return 302 https://www.youtube.com/results?q=$1; }
location ~^/\!gh\ (.+)$ { return 302 https://github.com/search?q=$1; }
location ~^/\!w\ (.+)$ { return 302 https://en.wikipedia.org/w/index.php?search=$1; }
location ~^/\!fa\ (.+)$ { return 302 https://glyphsearch.com/?library=font-awesome&query=$1; }
location ~^/\!emoji\ (.+)$ { return 302 https://emojipedia.org/search/?q=$1; }
location ~^/\!\ (.+)$ { return 404; }
location ~^/(.+)(\ ?)!(.+)($|\ ) { return 302 "/!$3 $1 $4"; }
location ~^/ip$ { add_header Content-Type text/plain; return 200 "${remote_addr}\n"; }
location ~^/useragent$ { add_header Content-Type text/plain; return 200 $http_user_agent; }
location ~^/(.+)$ { return 302 https://www.google.de/search?q=$1; }
location ~^/$ {
if ($arg_q) { return 302 /$arg_q; }
return 200 '<!DOCTYPE html><html><head><title>${host}</title><link rel="search" type="application/opensearchdescription+xml" title="${host}" href="https://${host}/opensearch.xml"></head><body><div style="position:fixed;top:50%;left:50%;width:400px;text-align:center;margin-left:-200px;height:280px;margin-top:-140px;"><img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMS41IDMxLjUiPjxwYXRoIHN0eWxlPSJmaWxsOiMwMDAwMDA7IiBkPSJNMy40LDMuNGMtNC41LDQuNS00LjUsMTEuOCwwLDE2LjNjNC4yLDQuMiwxMC45LDQuNSwxNS40LDAuOGwxMSwxMWwxLjctMS43bC0xMS0xMWMzLjctNC41LDMuNC0xMS4yLTAuOC0xNS40QzE1LjItMS4xLDcuOS0xLjEsMy40LDMuNHpNMTguMSwxOGMtMy42LDMuNi05LjUsMy42LTEzLjEsMEMxLjQsMTQuNCwxLjQsOC41LDUsNC45YzMuNi0zLjYsOS41LTMuNiwxMy4xLDBDMjEuNyw4LjUsMjEuNywxNC40LDE4LjEsMTh6Ii8+PC9zdmc+Cg==" style="width:200px;margin-bottom:20px;" /><br /><form method=get><input style="width:300px" name="q" type="text" autofocus size="50" /><input style="width:70px" type="submit" value="Search" /></div></body></html>';
default_type text/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment