Skip to content

Instantly share code, notes, and snippets.

@twilson63
Created May 20, 2018 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twilson63/4ee71a26b18500de9f37ca05b5186b3b to your computer and use it in GitHub Desktop.
Save twilson63/4ee71a26b18500de9f37ca05b5186b3b to your computer and use it in GitHub Desktop.
Install CouchDB Server on AWS using Bitnami and LetsEncrypt

How to install CouchDB on AWS in 5 minutes

Install CouchDB

Create an AWS Account, then open the console at EC2 and launch a bitnami couchdb

  • Create an aws account

https://console.aws.amazon.com

  • Go to the EC2 Service Link in the console

https://us-west-1.console.aws.amazon.com/ec2/v2/home?region=us-west-1#Home:

  • Click Launch Instance
  • Click AWS Market Place
  • Search for CouchDB
  • Select the Free Tier Eligible
    • click continue
    • select t2.micro
    • add 20 GB storage
    • add name tag with value
    • make sure the security group has ports 22, 80, 443 open
    • click launch and generate or use a keypair

Install nginx

  • ssh into your instance

`ssh -i [your key] bitnami@[your public dns]

  • run the following cmds:
sudo apt-get update -y
sudo apt-get install nginx -y
  • edit the default nginx file

sudo nano /etc/nginx/sites-available/default

Comment out root and index Change the server_name to the sub-domain you will be using ex: db.example.com

Replace the location with the following proxy info

location / {
  proxy_pass http://localhost:5984;
  proxy_redirect off;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Ssl on;
}

location ~ ^/(.*)_changes {
  proxy_pass http://localhost:5984;
  proxy_redirect off;
  proxy_buffering off;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
  • save file, then reload
sudo nginx -t
sudo systemctl reload nginx

Create a A Record to your server

Using your DNS you need to create an A record pointing to the ip of your server

now dns add exampe.com db A [ip address]

Install LetsEncrypt

Still in the ssh shell we need to run the following cmds:

sudo add-apt-repository ppa:certbot/certbot
  • press ENTER
sudo apt-get update -y
sudo apt-get install python-certbot-nginx -y
  • run the cert bot script
sudo certbot --nginx -d db.example.com

Fin

@twilson63
Copy link
Author

Should turn this into an automated script that can run automatically maybe compile a cli with pkg to ship from s3 to run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment