sudo apt-get update
sudo apt-get upgrade
sudo apt-get install redis-server
sudo apt-get install python-dev python-pip python-software-properties
openssl rand -base64 32 | sed "s/[+=\/:]//g"
redis_port: 6379 # Redis port
redis_host: localhost # Redis host
redis_prefix: sixpack # all Redis keys will be prefixed with this
redis_db: 1 # DB number in redis
# The regex to match for robots
robot_regex: $^|trivial|facebook|MetaURI|butterfly|google|amazon|goldfire|sleuth|xenu|msnbot|bing|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg|pingdom|bot|yahoo|slurp|java|fetch|spider|url|crawl|oneriot|abby|commentreader|twiceler
# ignored_ip_addresses: [] # List of IP
#
# asset_path: gen # Path for compressed assets to live. This path is RELATIVE to sixpack/static
secret_key: <secretkey> # secret key, required for sixpack-web to run
sudo pip install sixpack
sudo pip install gunicorn
sudo apt-get install supervisor
sudo mkdir /var/log/sixpack
sudo vim /etc/supervisor/conf.d/sixpack.conf
[program:sixpack]
command=gunicorn sixpack.server:start --bind unix:/tmp/sixpack.sock -w 5 --access-logfile /var/log/sixpack/gunicorn-access.log
autostart=true
autorestart=true
stdout_logfile = /var/log/sixpack/supervisor-sixpack.log ; Where to write log messages
redirect_stderr = true ; Save stderr in the same log
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8 ; Set UTF-8 as default encoding
sudo vim /etc/supervisor/conf.d/sixpackweb.conf
[program:sixpackweb]
command=gunicorn sixpack.web:start --bind unix:/tmp/sixpackweb.sock -w 2 --access-logfile /var/log/sixpack/sixpackweb-gunicorn-access.log
autostart=true
autorestart=true
stdout_logfile = /var/log/sixpack/supervisor-sixpackweb.log ; Where to write log messages
redirect_stderr = true ; Save stderr in the same log
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8 ; Set UTF-8 as default encoding
sudo supervisorctl
> reread
> update
> start all
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
sudo service nginx start
sudo lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 62
Stepping: 4
CPU MHz: 2500.060
BogoMIPS: 5000.12
Hypervisor vendor: Xen
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 25600K
NUMA node0 CPU(s): 0
user www-data;
# make it equal to number of cores * number of CPUs
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
include /etc/nginx/sites-enabled/*;
}
sudo nginx -t
sudo apt-get install apache2-utils
openssl rand -base64 24 | sed "s/[+=\/:]//g"
sudo htpasswd -c /etc/nginx/.htpasswd sixpack
sudo htpasswd /etc/nginx/.htpasswd sixpackweb
cd /etc/nginx
sudo vim sites-available/sixpack
upstream sixpack {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/tmp/sixpack.sock fail_timeout=0;
}
server {
listen 80 default;
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://sixpack;
}
}
sudo vim sites-available/sixpackweb
upstream sixpackweb {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/tmp/sixpackweb.sock fail_timeout=0;
}
server {
listen 8080;
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://sixpackweb;
}
}
sudo ln -s /etc/nginx/sites-available/sixpack /etc/nginx/sites-enabled/sixpack
sudo ln -s /etc/nginx/sites-available/sixpackweb /etc/nginx/sites-enabled/sixpackweb
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx reload
@Valve This worked great for me. I'm up and running so thanks for sharing. One quick question for you though.
I need to serve things up over HTTPS and I'm hoping I can piggyback on top of Cloudflare's SSL instead of setting up my own certs. I've done this for other sites, but I'm not quite sure how to go about it with this configuration. I'm new to python and haven't really used Nginx all that much.
I've opened up port 443 on my EC2 box, an now I'm assuming i need to configure Nginx or the Virtual Host to serve up these requests. Anything you can do to point me in the right direction would be greatly appreciated.