cdxy.me
Cyber Security / Data Science / Trading

Requirements

apt-get install

  • virtualenv
  • python-dev
  • supervisor
  • nginx
  • git

(venv) pip install

  • uwsgi

uWSGI

uwsgi.ini

[uwsgi]
socket = 127.0.0.1:8080
wsgi-file = wsgi.py
callable = app
processes = 4
threads = 2

wsgi.py

# !/usr/bin/env python
#  -*- coding: utf-8 -*-
from app1 import create_app

app = create_app('app1.config.ProdConfig')

Nginx

nginx.conf

server{
    listen 443 ssl;
    listen 80;
    server_name www.cdxy.me;

       ssl on;
       ssl_certificate /xxx/www.cdxy.me.crt;
       ssl_certificate_key /xxx/cdxy.key;
       error_page 497  https://$host$uri?$args;
       ssl_session_timeout 5m;

       ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
       ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
       ssl_prefer_server_ciphers on;

    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:8080;
        uwsgi_param UWSGI_PYHOME /xxx/flask_env; # virtualenv
        uwsgi_param UWSGI_CHDIR  /xxx/webapp; # Flask
        uwsgi_param UWSGI_SCRIPT wsgi:app; # wsgi:flask-app-obj
    }

    location /static {
        alias /xxx/webapp/app1/static; # Flask Static Folder
    }
}

supervisor

sv.conf

[program:webapp]
command=/xxx/flask_env/bin/uwsgi /xxx/webapp/uwsgi.ini
directory=/xxx/webapp
user=web
stdout_logfile=/xxx/uwsgi_supervisor.log
autostart=true
autorestart=true