|
| 1 | +# 3. Howto Install on AWS |
| 2 | + |
| 3 | +We will do demo setup for the following scenario: |
| 4 | + |
| 5 | + * GitHub Page we want to secure: |
| 6 | + * https://comsysto.github.io/github-pages-basic-auth-proxy/086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3/ |
| 7 | + * This is a gh-pages branch of a public repo. In real scenario this would be a private repo and no one could guess the obfuscator. |
| 8 | + * Contents of gh-pages: https://github.com/comsysto/github-pages-basic-auth-proxy/tree/gh-pages |
| 9 | + * Proxy-URL we want to use: |
| 10 | + * https://my-secure-github-page.comsysto.com/ |
| 11 | + * This is a `ec2.micro` Instance on AWS which is configured as described below. |
| 12 | + |
| 13 | +### 3.1 Prerequisites |
| 14 | + |
| 15 | + * You will need nginx, python 3 and git. |
| 16 | + * on Ubuntu: `apt-get install git nginx python3-setuptools build-essential python3-dev` |
| 17 | + * optional a ssl certificate |
| 18 | + |
| 19 | +### 3.2 nginx setup |
| 20 | + |
| 21 | +We need some kind of vhost with SSL that proxies everything through to our python proxy. |
| 22 | + |
| 23 | +``` |
| 24 | +server { |
| 25 | + listen 443; |
| 26 | + server_name my-secure-github-page.comsysto.com; |
| 27 | +
|
| 28 | + ssl on; |
| 29 | + ssl_certificate /etc/ssl/comsysto.crt; |
| 30 | + ssl_certificate_key /etc/ssl/comsysto.key; |
| 31 | + ssl_session_timeout 5m; |
| 32 | + ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; |
| 33 | + ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; |
| 34 | + ssl_prefer_server_ciphers on; |
| 35 | + |
| 36 | + location / { |
| 37 | + proxy_pass http://127.0.0.1:8881/; |
| 38 | + } |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +### 3.3 python proxy setup |
| 43 | + |
| 44 | +Install proxy |
| 45 | +``` |
| 46 | +git clone https://github.com/comsysto/github-pages-basic-auth-proxy.git |
| 47 | +cd github-pages-basic-auth-proxy |
| 48 | +sudo python3 setup.py install |
| 49 | +``` |
| 50 | + |
| 51 | +Run Proxy |
| 52 | + |
| 53 | + * proxy that allows only members of the organization to access page: (owner must be an GitHub Organization) |
| 54 | + |
| 55 | +``` |
| 56 | +$> cs-gh-proxy -e wsgi -p 8881 --authType onlyGitHubOrgUsers --owner comsysto --repository github-pages-basic-auth-proxy --obfuscator 086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3 |
| 57 | +``` |
| 58 | + |
| 59 | + * proxy that allows all GitHub Users to access page: (owner can be GitHub Organization or normal user) |
| 60 | + |
| 61 | +``` |
| 62 | +$> cs-gh-proxy -e wsgi -p 8881 --authType allGitHubUsers --owner comsysto --repository github-pages-basic-auth-proxy --obfuscator 086e41eb6ff7a50ad33ad742dbaa2e70b75740c4950fd5bbbdc71981e6fe88e3 |
| 63 | +``` |
| 64 | + |
| 65 | + * Howto run python server as daemon |
| 66 | + * first [install daemonize](http://software.clapper.org/daemonize/) |
| 67 | + * now create script `/opt/run-gh-proxy.sh` |
| 68 | + * put run command (see above) in script |
| 69 | + * run as daemon with `/usr/local/sbin/daemonize -p /var/run/cs-gh-proxy.pid -l /var/run/cs-gh-proxy.lock /opt/run-gh-proxy.sh` |
| 70 | + * Now you can write some scripts to check for pidfile or port |
| 71 | + * lockfile ensures that there will only be a single instance |
0 commit comments