Skip to content

Instantly share code, notes, and snippets.

@muhqu
Last active December 16, 2015 13:39
Show Gist options
  • Select an option

  • Save muhqu/5443129 to your computer and use it in GitHub Desktop.

Select an option

Save muhqu/5443129 to your computer and use it in GitHub Desktop.
#!/bin/bash
sudo apt-get update
sudo apt-get install nginx -y
echo '
resolver 172.16.0.23; # AWS DNS Server
resolver_timeout 5s;
upstream search {
server search-YOUR-ENDPOINT-HERE.us-east-1.cloudsearch.amazonaws.com:80;
}
upstream doc {
server doc-YOUR-ENDPOINT-HERE.us-east-1.cloudsearch.amazonaws.com:80;
}
server {
listen 8081;
access_log off;
proxy_pass http://search;
}
server {
listen 8082;
access_log off;
proxy_pass http://doc;
}
' | sudo tee /etc/nginx/sites-available/cloudsearch-proxy >/dev/null
test -e /etc/nginx/sites-enabled/default && sudo rm /etc/nginx/sites-enabled/default;
test ! -e /etc/nginx/sites-enabled/cloudsearch-proxy && sudo ln -s /etc/nginx/sites-{available,enabled}/cloudsearch-proxy;
sudo /etc/init.d/nginx restart

How To Start the EC2 Instance?

# Start Ubuntu 10.04 LTS (Lucid Lynx) 64-bit US-East (ami-1136fb78)
ec2-run-instances ami-1136fb78 -t m1.small -g cloudsearch-proxy -f ./cloudsearch-http-proxy-init.sh

How to do CloudSearch requests?

# for search use port 8081
curl -X GET "http://$EC2_PUBLIC_HOSTNAME:8081/2011-02-01/search?q=..."

# for documents use port 8082
curl -X POST "http://$EC2_PUBLIC_HOSTNAME:8082/2011-02-01/documents/batch" -d ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment