|
| 1 | +Running in Production |
| 2 | +===================== |
| 3 | + |
| 4 | +This guide will walk you through how to setup DefectDojo for running in production using Ubuntu 16.04, nginx, and uwsgi. |
| 5 | + |
| 6 | +*Install, Setup, and Activate Virtualenv* |
| 7 | + |
| 8 | +.. code-block:: console |
| 9 | +
|
| 10 | + pip install virtualenv |
| 11 | +
|
| 12 | + virtualenv dojo |
| 13 | +
|
| 14 | + source my_project/bin/activate |
| 15 | +
|
| 16 | +**Install Dojo** |
| 17 | + |
| 18 | +.. code-block:: console |
| 19 | +
|
| 20 | + cd django-DefectDojo |
| 21 | +
|
| 22 | + ./install.bash |
| 23 | +
|
| 24 | +**Install Uwsgi** |
| 25 | + |
| 26 | +.. code-block:: console |
| 27 | +
|
| 28 | + pip install uwsgi |
| 29 | +
|
| 30 | +**Install WKHTML** |
| 31 | + |
| 32 | +from inside the django-DefectDojo/ directory execute: |
| 33 | + |
| 34 | +.. code-block:: console |
| 35 | +
|
| 36 | + ./reports.sh |
| 37 | +
|
| 38 | +**Disable Debugging** |
| 39 | + |
| 40 | +Using the text-editor of your choice, change ``DEBUG`` in django-DefectDojo/dojo/settings.py to: |
| 41 | + |
| 42 | +.. code-block:: console |
| 43 | +
|
| 44 | + `DEBUG = False` |
| 45 | +
|
| 46 | +**Start Celery and Beats** |
| 47 | + |
| 48 | +From inside the django-DefectDojo/ directory execute: |
| 49 | + |
| 50 | +.. code-block:: console |
| 51 | +
|
| 52 | + celery -A dojo worker -l info --concurrency 3 |
| 53 | +
|
| 54 | + celery beat -A dojo -l info |
| 55 | +
|
| 56 | +It is recommended that you daemonized both these processes with the sample configurations found `here`_ and `here.`_ |
| 57 | + |
| 58 | +.. _here: https://github.com/celery/celery/blob/3.1/extra/supervisord/celeryd.conf |
| 59 | +.. _here.: https://github.com/celery/celery/blob/3.1/extra/supervisord/celerybeat.conf |
| 60 | + |
| 61 | +However, for a quick setup you can use the following to run both in the background |
| 62 | + |
| 63 | +.. code-block:: console |
| 64 | +
|
| 65 | + celery -A dojo worker -l info --concurrency 3 & |
| 66 | +
|
| 67 | + celery beat -A dojo -l info & |
| 68 | +
|
| 69 | +*Start Uwsgi* |
| 70 | + |
| 71 | +From inside the django-DefectDojo/ directory execute: |
| 72 | + |
| 73 | +.. code-block:: console |
| 74 | +
|
| 75 | + uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7 |
| 76 | +
|
| 77 | +It is recommended that you use an Upstart job or a @restart cron job to launch uwsgi on reboot. However, if you’re in a hurry you can use the following to run it in the background: |
| 78 | + |
| 79 | +.. code-block:: console |
| 80 | +
|
| 81 | + uwsgi --socket :8001 --wsgi-file wsgi.py --workers 7 & |
| 82 | +
|
| 83 | +*NGINX Configuration* |
| 84 | + |
| 85 | +Everyone feels a little differently about nginx settings, so here are the barebones to add your to your nginx configuration to proxy uwsgi: |
| 86 | + |
| 87 | +.. code-block:: json |
| 88 | +
|
| 89 | + upstream django { |
| 90 | + |
| 91 | + server 127.0.0.1:8001; |
| 92 | + } |
| 93 | +
|
| 94 | + location /dojo/static/ { |
| 95 | + alias /data/prod_dojo/django-DefectDojo/static/; |
| 96 | + } |
| 97 | +
|
| 98 | + location /dojo/media/ { |
| 99 | + alias /data/prod_dojo/django-DefectDojo/media/; |
| 100 | + } |
| 101 | +
|
| 102 | +
|
| 103 | + location /dojo { |
| 104 | + uwsgi_pass django; |
| 105 | + include /data/prod_dojo/django-DefectDojo/wsgi_params; |
| 106 | + } |
| 107 | +
|
| 108 | +*That's it!* |
0 commit comments