diff --git a/README.md b/README.md index 9cadd29..8f8b795 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ And restart xdm: service xdm restart ``` - # Installation of scrapysplashwrapper You need a running splash instance, preferably on docker: https://splash.readthedocs.io/en/stable/install.html @@ -80,3 +79,37 @@ pew toggleglobalsitepackages # PyQt4 is not easily installable in a virtualenv pip install -r requirements.txt pip install -e . ``` +# Run the app locally + +```bash +export DISPLAY=:0 +export FLASK_APP=lookyloo +flask run +``` + +## With a reverse proxy (Nginx) + +```bash +pip install uwsgi +``` + +### Config files + +You have to configure the two following files: + +* `etc/nginxsites-available/lookyloo` +* `etc/systemd/system/lookyloo.service` + +And copy them to the appropriate directories and run the following command: +`sudo ln -s /etc/nginx/sites-available/lookyloo /etc/nginx/sites-enabled` + +Make sure everything is working: + +```bash +sudo systemctl start lookyloo +sudo systemctl enable lookyloo +sudo nginx -t +# If it is cool: +sudo service restart nginx +``` + diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/etc/nginx/sites-available/lookyloo b/etc/nginx/sites-available/lookyloo new file mode 100644 index 0000000..fc4a417 --- /dev/null +++ b/etc/nginx/sites-available/lookyloo @@ -0,0 +1,9 @@ +server { + listen 80; + server_name server_domain_or_IP; + + location / { + include uwsgi_params; + uwsgi_pass unix:/home//lookyloo/lookyloo.sock; + } +} diff --git a/etc/systemd/system/lookyloo.service b/etc/systemd/system/lookyloo.service new file mode 100644 index 0000000..c2bd9be --- /dev/null +++ b/etc/systemd/system/lookyloo.service @@ -0,0 +1,16 @@ +[Unit] +Description=uWSGI instance to serve lookyloo +After=network.target + +[Service] +User=www-data +Group=www-data +WorkingDirectory=/home//lookyloo +Environment="PATH=/home///bin" +ExecStart=/home///bin/uwsgi --ini lookyloo.ini +Environment=DISPLAY=:0 +Environment=FLASK_APP=lookyloo + +[Install] +WantedBy=multi-user.target + diff --git a/lookyloo.ini b/lookyloo.ini new file mode 100644 index 0000000..33457ec --- /dev/null +++ b/lookyloo.ini @@ -0,0 +1,11 @@ +[uwsgi] +module = wsgi:app + +master = true +processes = 5 + +socket = lookyloo.sock +chmod-socket = 660 +vacuum = true + +die-on-term = true diff --git a/lookyloo/__init__.py b/lookyloo/__init__.py index 0d3a366..0829c31 100644 --- a/lookyloo/__init__.py +++ b/lookyloo/__init__.py @@ -5,7 +5,7 @@ import json from har2tree import CrawledTree, hostname_treestyle from scrapysplashwrapper import crawl -from ete3_webserver import NodeActions, WebTreeHandler +from .ete3_webserver import NodeActions, WebTreeHandler from flask import Flask, render_template, request from flask_bootstrap import Bootstrap diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..2b6acbb --- /dev/null +++ b/wsgi.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from lookyloo import app + +if __name__ == "__main__": + app.run()