Skip to content

Instantly share code, notes, and snippets.

@dmdeller
Created November 28, 2011 19:46
Show Gist options
  • Save dmdeller/1401727 to your computer and use it in GitHub Desktop.
Save dmdeller/1401727 to your computer and use it in GitHub Desktop.
DuckDuckGo nginx config for handling Safari search bar requests
server {
server_name search.yahoo.com;
# only handle requests from Safari search bar
if ($args ~ fr=aaplw.*p=) {
rewrite ^/search https://duckduckgo.com/?q=$arg_p? break;
}
# attempt to redirect other requests back to Yahoo, using alternative server name
rewrite ^ http://search.ystg1.b.yahoo.com$request_uri? break;
}
server {
server_name www.google.com;
# only handle requests from Safari search bar
if ($args ~ client=safari.*q=) {
rewrite ^/search https://duckduckgo.com/?q=$arg_q? break;
}
# redirect other requests to info page explaining what happened
rewrite ^ http://help.duckduckgo.com/customer/portal/articles/255678? break;
}
server {
server_name www.bing.com;
# only handle requests from Safari search bar
if ($args ~ q=.*form=APMCS1) {
rewrite ^/search https://duckduckgo.com/?q=$arg_q? break;
}
# redirect other requests to info page explaining what happened
rewrite ^ http://help.duckduckgo.com/customer/portal/articles/255682? break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment