Merge remote-tracking branch 'upstream/master' into multipleMerges

pull/29/head
Sami Mokaddem 2018-01-15 14:19:44 +01:00
commit 2cc957c87e
5 changed files with 84 additions and 3 deletions

View File

@ -88,6 +88,69 @@ optional arguments:
The URL to connect to
```
# Deploy in production using mod_wsgi
Install Apache's mod-wsgi for Python3
```bash
sudo apt-get install libapache2-mod-wsgi-py3
```
Caveat: If you already have mod-wsgi installed for Python2, it will be replaced!
```bash
The following packages will be REMOVED:
libapache2-mod-wsgi
The following NEW packages will be installed:
libapache2-mod-wsgi-py3
```
Configuration file `/etc/apache2/sites-available/misp-dashboard.conf` assumes that `misp-dashboard` is cloned into `var/www/misp-dashboard`. It runs as user `misp` in this example. Change the permissions to folder and files accordingly.
```
<VirtualHost *:8000>
ServerAdmin admin@misp.local
ServerName misp.local
DocumentRoot /var/www/misp-dashboard
WSGIDaemonProcess misp-dashboard \
user=misp group=misp \
python-home=/var/www/misp-dashboard/DASHENV \
processes=1 \
threads=15 \
maximum-requests=5000 \
listen-backlog=100 \
queue-timeout=45 \
socket-timeout=60 \
connect-timeout=15 \
request-timeout=60 \
inactivity-timeout=0 \
deadlock-timeout=60 \
graceful-timeout=15 \
eviction-timeout=0 \
shutdown-timeout=5 \
send-buffer-size=0 \
receive-buffer-size=0 \
header-buffer-size=0 \
response-buffer-size=0 \
server-metrics=Off
WSGIScriptAlias / /var/www/misp-dashboard/misp-dashboard.wsgi
<Directory /var/www/misp-dashboard>
WSGIProcessGroup misp-dashboard
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
LogLevel info
ErrorLog /var/log/apache2/misp-dashboard.local_error.log
CustomLog /var/log/apache2/misp-dashboard.local_access.log combined
ServerSignature Off
</VirtualHost>
```
# License
Images and logos are handmade for:
- rankingMISPOrg/

View File

@ -1,3 +1,7 @@
[Server]
host = localhost
port = 8001
[Dashboard]
#hours
graph_log_refresh_rate = 1

View File

@ -174,8 +174,15 @@ class Geo_helper:
def ip_to_coord(self, ip):
resp = self.reader.city(ip)
lat = float(resp.location.latitude)
lon = float(resp.location.longitude)
try:
lat = float(resp.location.latitude)
lon = float(resp.location.longitude)
except TypeError: # No location, try to use iso_code instead
self.logger.info('no location in geIP.database response for ip: {}'.format(ip))
iso_code = resp.registered_country.iso_code #if no iso_code, throws
coord = self.country_code_to_coord[iso_code.lower()] # countrycode is in upper case
lat = float(coord['lat'])
lon = float(coord['long'])
# 0.0001 correspond to ~10m
# Cast the float so that it has the correct float format
lat_corrected = float("{:.4f}".format(lat))

4
misp-dashboard.wsgi Normal file
View File

@ -0,0 +1,4 @@
import sys,os,os.path
sys.path.insert(0, os.path.dirname(__file__))
os.environ["DASH_CONFIG"] = os.path.join(os.path.dirname(__file__), "config")
from server import app as application

View File

@ -23,6 +23,9 @@ cfg.read(configfile)
logger = logging.getLogger('werkzeug')
logger.setLevel(logging.ERROR)
server_host = cfg.get("Server", "host")
server_port = cfg.getint("Server", "port")
app = Flask(__name__)
redis_server_log = redis.StrictRedis(
@ -550,4 +553,4 @@ def getGenericTrendingOvertime():
return jsonify(data)
if __name__ == '__main__':
app.run(host='localhost', port=8001, threaded=True)
app.run(host=server_host, port=server_port, threaded=True)