Git Product home page Git Product logo

happyhour's Introduction

Configuring server

Start with AWS Lightsail Ubuntu 18.04 LTS

Install Nginx

sudo apt update sudo apt upgrade sudo apt install nginx

Configure domain name

Check public IP address in browser (HTTP). In Lightsail > Networking, add static IP address to server. Check static IP address in browser (HTTP). In AWS > Route53 > Hosted Zone for ianwdavis.com, create an A record for happyhour.ianwdavis.com pointing to the static IP. Wait for this to take effect -- may be a few minutes. Confirm new domain name in browser (HTTP).

Configure SSH

In ~/.ssh/config:

Host happyhour
HostName happyhour.ianwdavis.com
User ubuntu
IdentityFile ~/.ssh/LightsailDefaultKey-us-east-1.pem

Push code

git clone https://github.com/iwd32900/happyhour.git
cd happyhour
sudo apt install python3-pip python3-venv
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
mkdir static
python3 server.py

Configure Nginx as reverse proxy

Resources:

cd /etc/nginx/sites-enabled/
sudo ln -s ~/happyhour/happyhour.nginx

In /etc/nginx/nginx.conf:

gzip off;

Having gzip on leads to lots of 400 errors with WebSockets!

Test config: sudo nginx -t Restart: sudo systemctl restart nginx

Configure SSL

sudo apt install python3-certbot-nginx sudo certbot --nginx -d happyhour.ianwdavis.com Test to make sure auto-renewal is working: sudo certbot renew --dry-run

Make Python start automatically

sudo apt install monit
cd /etc/monit/conf-enabled/
sudo ln -s ~/happyhour/happyhour.monit

In /etc/monit/monitrc, uncomment:

set httpd port 2812 and
    use address localhost  # only accept connection from localhost
    allow localhost        # allow localhost to connect to the server and

and do sudo monit reload; sudo monit status.

The thing that took me forever was to figure out that happyhour.sh had to start the server as a background process. Otherwise, startup timed out, and Monit killed the process after 30 sec.

Deploy updates

cd happyhour
git pull
pgrep -f happyhour    # optional
sudo monit restart happyhour
pgrep -f happyhour    # optional, should show different process ID

Server security updates

It looks like unattended-upgrades is enabled by default on the Lightsail Ubuntu 18.04 instances.

Nginx log analysis

sudo apt install goaccess goaccess --log-format=COMBINED <(zcat -f /var/log/nginx/access.log*) --ignore-crawlers

TODO

  • allow naming tables
  • broadcast chat messages to all participants
  • re-broadcast which room people are in periodically (to make sure things are in sync)

happyhour's People

Contributors

iwd32900 avatar

Watchers

James Cloos 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.