From 527662968aec1065c0c5c24f051bf6693961b291 Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Wed, 29 Apr 2020 16:58:27 +0200 Subject: [PATCH] move files, add installation guide and configs --- README.md | 20 +++++----- {docs => assets}/config-gui.png | Bin {docs => assets}/control.png | Bin {docs => assets}/landing-page.png | Bin {docs => assets}/logging.png | Bin {docs => assets}/login.png | Bin {docs => assets}/media-upload.png | Bin {docs => assets}/media.png | Bin {docs => assets}/message.png | Bin docs/ffplayout-api.service | 13 ++++++ docs/ffplayout.conf | 63 ++++++++++++++++++++++++++++++ docs/install.md | 46 ++++++++++++++++++++++ 12 files changed, 133 insertions(+), 9 deletions(-) rename {docs => assets}/config-gui.png (100%) rename {docs => assets}/control.png (100%) rename {docs => assets}/landing-page.png (100%) rename {docs => assets}/logging.png (100%) rename {docs => assets}/login.png (100%) rename {docs => assets}/media-upload.png (100%) rename {docs => assets}/media.png (100%) rename {docs => assets}/message.png (100%) create mode 100644 docs/ffplayout-api.service create mode 100644 docs/ffplayout.conf create mode 100644 docs/install.md diff --git a/README.md b/README.md index acd37db7..59717272 100644 --- a/README.md +++ b/README.md @@ -3,30 +3,32 @@ ffplayout-gui This is the dev version v2.0.0 from ffplayout GUI. +Check [install.md](docs/install.md) for installation + **This version is not ready to use!!** -## concept previews: +## some impressions belows: #### Login -![login](/docs/login.png) +![login](/assets/login.png) #### Landing Page -![landing-page](/docs/landing-page.png) +![landing-page](/assets/landing-page.png) #### Control Page -![control](/docs/control.png) +![control](/assets/control.png) #### Media Page -![media](/docs/media.png) +![media](/assets/media.png) #### Media Page / Upload -![media-upload](/docs/media-upload.png) +![media-upload](/assets/media-upload.png) #### Message Page -![message](/docs/message.png) +![message](/assets/message.png) #### Logging Page -![logging](/docs/logging.png) +![logging](/assets/logging.png) #### Configuration Page / GUI -![config-gui](/docs/config-gui.png) +![config-gui](/assets/config-gui.png) diff --git a/docs/config-gui.png b/assets/config-gui.png similarity index 100% rename from docs/config-gui.png rename to assets/config-gui.png diff --git a/docs/control.png b/assets/control.png similarity index 100% rename from docs/control.png rename to assets/control.png diff --git a/docs/landing-page.png b/assets/landing-page.png similarity index 100% rename from docs/landing-page.png rename to assets/landing-page.png diff --git a/docs/logging.png b/assets/logging.png similarity index 100% rename from docs/logging.png rename to assets/logging.png diff --git a/docs/login.png b/assets/login.png similarity index 100% rename from docs/login.png rename to assets/login.png diff --git a/docs/media-upload.png b/assets/media-upload.png similarity index 100% rename from docs/media-upload.png rename to assets/media-upload.png diff --git a/docs/media.png b/assets/media.png similarity index 100% rename from docs/media.png rename to assets/media.png diff --git a/docs/message.png b/assets/message.png similarity index 100% rename from docs/message.png rename to assets/message.png diff --git a/docs/ffplayout-api.service b/docs/ffplayout-api.service new file mode 100644 index 00000000..429322ee --- /dev/null +++ b/docs/ffplayout-api.service @@ -0,0 +1,13 @@ +[Unit] +Description=ffplayout api daemon +After=network.target + +[Service] +WorkingDirectory=/var/www/ffplayout/ffplayout +ExecStart=/var/www/ffplayout/venv/bin/gunicorn --workers 6 --timeout 300 --log-level=info --log-file=- --access-logfile=- --bind unix:/var/www/ffplayout/ffplayout/ffplayout.sock ffplayout.wsgi:application +KillMode=process +User=www-data +Group=www-data + +[Install] +WantedBy=multi-user.target diff --git a/docs/ffplayout.conf b/docs/ffplayout.conf new file mode 100644 index 00000000..383bf227 --- /dev/null +++ b/docs/ffplayout.conf @@ -0,0 +1,63 @@ +map $sent_http_content_type $expires { + "text/html" 1h; # set this to your needs + "text/html; charset=utf-8" 1h; # set this to your needs + default 1d; # set this to your needs +} + +server { + listen 127.0.1.4; + + server_name ffplayout.local ffplayout; + + gzip on; + gzip_types text/plain application/xml text/css application/javascript; + gzip_min_length 1000; + + charset utf-8; + + add_header X-Frame-Options SAMEORIGIN; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; + + location / { + if ($http_origin ~ '^https?://(localhost|ffplayout\.local|ffplayout)') { + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always; + } + + if ($request_method = OPTIONS ) { + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + + root /var/www/ffplayout/ffplayout/frontend/dist/; + + } + + location ~ ^/(api|admin) { + if ($http_origin ~ '^https?://(localhost|ffplayout\.local|ffplayout)') { + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always; + } + + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://unix:/var/www/ffplayout/ffplayout/ffplayout.sock; + } + + location /static/ { + alias /var/www/ffplayout/ffplayout/static/; + } + + access_log /var/log/nginx/ffplayout_access.log; + error_log /var/log/nginx/ffplayout_error.log warn; +} diff --git a/docs/install.md b/docs/install.md new file mode 100644 index 00000000..6f7db955 --- /dev/null +++ b/docs/install.md @@ -0,0 +1,46 @@ +# Manuel Installation Guide + +**We are assuming that the system user `www-data` will run all processes!** + +### API Setup + +##### Preparation +- clone repo to `/var/www/ffplayout` +- cd in root folder from repo +- add virtual environment: `virtualenv -p python3 venv` +- run `source ./venv/bin/activate` +- install dependencies: `pip install -r requirements-base.txt` +- cd in `ffplayout` +- generate secret: `python manage.py shell -c 'from django.core.management import utils; print(utils.get_random_secret_key())'` +- open **ffplayout/settings.py** +- past secret key in variable `SECRET_KEY` +- change `DEBUG = True` to `DEBUG = False` +- set `ALLOWED_HOSTS` with correct URL +- set URL in `CORS_ORIGIN_WHITELIST` +- collect staticfiles: `python manage.py collectstatic` + +##### System Setup +- copy **docs/ffplayout-api.service** from root folder to **/etc/systemd/system/** +- enable service and start it: `systemctl enable ffplayout-api.service && systemctl start ffplayout-api.service` +- install **nginx** +- edit **docs/ffplayout.conf** + - set correct IP and `server_name` + - add domain `http_origin` test value + - add https redirection and SSL if is necessary +- copy **docs/ffplayout.conf** to **/etc/nginx/sites-available/** +- symlink config: `ln -s /etc/nginx/sites-available/ffplayout.conf /etc/nginx/sites-enabled/` +- restart nginx +- run `visudo` and add: +``` +www-data ALL = NOPASSWD: /bin/systemctl start ffplayout-engine.service, /bin/systemctl stop ffplayout-engine.service, /bin/systemctl reload ffplayout-engine.service, /bin/systemctl restart ffplayout-engine.service, /bin/systemctl status ffplayout-engine.service, /bin/systemctl is-active ffplayout-engine.service, /bin/journalctl -n 1000 -u ffplayout-engine.service +``` + +### Frontend + +**We need a recent version of npm** + +- go to folder **/var/www/ffplayout/ffplayout/frontend** +- install dependencies: `npm install` +- build app: `npm run build` + +Your frontend should be now in **/var/www/ffplayout/ffplayout/frontend/dist** folder, which we are included already in the nginx config. You can service now the GUI under your domain URL.