Coder Social home page Coder Social logo

odhom's Introduction

odhom

Proxy that starts/shutdown AWS instances on demand using HTTP headers

Depends on

  1. NodeJS >= 0.10.32
  2. Haproxy >= 1.4
  3. AWS CLI
  4. Ubuntu with upstart (can be run on other distros too)

Installing

Create a ROLE or an USER on AWS IAM giving access to start/stop EC2 instances for instances with the odhom-host tag. The minimum JSON permissions are:


{
    "Version": "2012-10-17",
    "Statement": [
         {
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances" 
            ],
            "Resource": [
                "*" 
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "ec2:StartInstances",
                "ec2:StopInstances" 
            ],
            "Condition": {
                "StringLike": {
                    "ec2:ResourceTag/odhom-host": "*" 
                }
            },
            "Resource": [
                "*" 
            ]
        },
	{
            "Effect": "Allow",
            "Action": [
                "route53:*",
            ],
            "Resource": [
                "*" 
            ]
        }
    ]
}

If you are using an USER instead of an instance role, you must update the credentials (./credentials) file with the correct keys.

Create an UBUNTU instance on AWS console, and remember to open the port 80 TCP. For every instance that you want odhom to manage, you must open the access from the odhom instance to the port that is listening, so that odhom will be able to proxy it.

SSH into your newly created instance and run script-bringup-ubuntu.sh to install the dependencies and odhom on /opt/odhom.

Starting and stoping :

sudo start odhom

sudo stop odhom

Adding machines to odhom

Add the tag with the key=odhom-host and the value with the fully qualyfied hostname to every instance that you want. Be aware that as soon as odhom detects it (it scans every 5 seconds) it will shut down the machine after 55 minutes of inactivity (Activity is equal to receiving a HTTP request to that hostname)

You can add multiple hostnames on the odhom-host value, splitting using a comma and no spaces, example: domain1.yourcompany.com,www.domain1.yourcompany.com

Configure your DNS settings so that these domains point to the ip address (or to the CNAME record) of the odhom machine. You can also use your hosts file for testing on your machine, if you prefer.

There is a log file under /opt/odhom/odhom.log

You can check if odhom is running accessing its ip address and adding a /odhom after it.

Verify that works by trying to access a hostname that is managed by odhom, and viewing it on your ec2 control panel. The instance should be changing the state from stopped to running. The browser holds the access until it detects that the instance is up and listening to port 80, and then it issues a 302 pointing to the same address to refresh it. On the second refresh, the proxy will send it to the correct destination.

odhom's People

Contributors

marcelovk avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.