grahamgilbert / Crypt-Server

A Django webapp to escrow filevault keys sent by the Crypt client app.
Apache License 2.0
121 stars 46 forks source link

502 Bad Gateway #39

Closed tkojames24 closed 7 years ago

tkojames24 commented 7 years ago

I am using the docker image macadmins/crypt-server. I am using Centos 7 and ubuntu as my docker host. I have tired this in multiple VMs and a local machine. When I visit localhost:8000 I get 502 Bad Gateway error. Is there anything I need to do to fix this? I am following the docker setup information.

grahamgilbert commented 7 years ago

Some logs would be helpful. docker logs whateveryoucalledcrypt

tkojames24 commented 7 years ago

Below is the docker logs. I think the issue might be the following error, "django.db.utils.OperationalError: unable to open database file" Do I have to set certain permissions for the db folder I create on the host maybe?

Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 367, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 305, in run_from_argv self.execute(*args, *cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 356, in execute output = self.handle(args, options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 83, in handle executor = MigrationExecutor(connection, self.migration_progress_callback) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 20, in init self.loader = MigrationLoader(self.connection) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 52, in init self.build_graph() File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 203, in build_graph self.applied_migrations = recorder.applied_migrations() File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 65, in applied_migrations self.ensure_schema() File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 52, in ensure_schema if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()): File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 233, in cursor cursor = self.make_cursor(self._cursor()) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 204, in _cursor self.ensure_connection() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 171, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 209, in get_new_connection conn = Database.connect(conn_params) django.db.utils.OperationalError: unable to open database file Copying '/home/docker/crypt/site_static/datatables-bootstrap.css' Copying '/home/docker/crypt/site_static/datatables-bootstrap.js' Copying '/home/docker/crypt/site_static/jquery.dataTables.min.js' Copying '/home/docker/crypt/site_static/style.css' Copying '/home/docker/crypt/site_static/bootstrap/css/bootstrap-responsive.css' Copying '/home/docker/crypt/site_static/bootstrap/css/bootstrap-responsive.min.css' Copying '/home/docker/crypt/site_static/bootstrap/css/bootstrap.css' Copying '/home/docker/crypt/site_static/bootstrap/css/bootstrap.min.css' Copying '/home/docker/crypt/site_static/bootstrap/img/glyphicons-halflings-white.png' Copying '/home/docker/crypt/site_static/bootstrap/img/glyphicons-halflings.png' Copying '/home/docker/crypt/site_static/bootstrap/js/bootstrap.js' Copying '/home/docker/crypt/site_static/bootstrap/js/bootstrap.min.js' Copying '/home/docker/crypt/site_static/css/bootstrap.css' Copying '/home/docker/crypt/site_static/css/bootstrap.min.css' Copying '/home/docker/crypt/site_static/css/mixins.css' Copying '/home/docker/crypt/site_static/css/styles.css' Copying '/home/docker/crypt/site_static/css/variables.css' Copying '/home/docker/crypt/site_static/css/plugins/dataTables.bootstrap.css' Copying '/home/docker/crypt/site_static/css/plugins/morris.css' Copying '/home/docker/crypt/site_static/css/plugins/social-buttons.css' Copying '/home/docker/crypt/site_static/css/plugins/timeline.css' Copying '/home/docker/crypt/site_static/css/plugins/metisMenu/metisMenu.css' Copying '/home/docker/crypt/site_static/css/plugins/metisMenu/metisMenu.min.css' Copying '/home/docker/crypt/site_static/fonts/glyphicons-halflings-regular.eot' Copying '/home/docker/crypt/site_static/fonts/glyphicons-halflings-regular.svg' Copying '/home/docker/crypt/site_static/fonts/glyphicons-halflings-regular.ttf' Copying '/home/docker/crypt/site_static/fonts/glyphicons-halflings-regular.woff' Copying '/home/docker/crypt/site_static/fonts/glyphicons-halflings-regular.woff2' Copying '/home/docker/crypt/site_static/img/atom-head-white.svg' Copying '/home/docker/crypt/site_static/img/sal-logo-white.svg' Copying '/home/docker/crypt/site_static/img/select2-spinner.gif' Copying '/home/docker/crypt/site_static/img/select2.png' Copying '/home/docker/crypt/site_static/img/select2x2.png' Copying '/home/docker/crypt/site_static/js/bootstrap.js' Copying '/home/docker/crypt/site_static/js/bootstrap.min.js' Copying '/home/docker/crypt/site_static/js/jquery-1.11.0.js' Copying '/home/docker/crypt/site_static/js/less-1.4.2.min.js' Copying '/home/docker/crypt/site_static/js/main.js' Copying '/home/docker/crypt/site_static/js/plugins/dataTables/dataTables.bootstrap.js' Copying '/home/docker/crypt/site_static/js/plugins/dataTables/jquery.dataTables.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/base.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/changelists.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/dashboard.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/fonts.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/forms.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/login.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/rtl.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/css/widgets.css' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/fonts/LICENSE.txt' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/fonts/README.txt' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/fonts/Roboto-Bold-webfont.woff' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/fonts/Roboto-Light-webfont.woff' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/fonts/Roboto-Regular-webfont.woff' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/LICENSE' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/README.txt' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/calendar-icons.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-addlink.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-alert.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-calendar.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-changelink.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-clock.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-deletelink.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-no.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-unknown-alt.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-unknown.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/icon-yes.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/inline-delete.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/search.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/selector-icons.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/sorting-icons.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/tooltag-add.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/tooltag-arrowright.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/gis/move_vertex_off.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/img/gis/move_vertex_on.svg' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/SelectBox.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/SelectFilter2.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/actions.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/actions.min.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/calendar.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/cancel.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/change_form.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/collapse.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/collapse.min.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/core.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/inlines.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/inlines.min.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/jquery.init.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/popup_response.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/prepopulate.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/prepopulate.min.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/prepopulate_init.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/timeparse.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/urlify.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/vendor/jquery/LICENSE-JQUERY.txt' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/vendor/jquery/jquery.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/vendor/jquery/jquery.min.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/vendor/xregexp/LICENSE-XREGEXP.txt' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.js' Copying '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/js/vendor/xregexp/xregexp.min.js' Copying '/usr/local/lib/python2.7/dist-packages/django_extensions/static/django_extensions/css/jquery.autocomplete.css' Copying '/usr/local/lib/python2.7/dist-packages/django_extensions/static/django_extensions/img/indicator.gif' Copying '/usr/local/lib/python2.7/dist-packages/django_extensions/static/django_extensions/js/jquery.ajaxQueue.js' Copying '/usr/local/lib/python2.7/dist-packages/django_extensions/static/django_extensions/js/jquery.autocomplete.js' Copying '/usr/local/lib/python2.7/dist-packages/django_extensions/static/django_extensions/js/jquery.bgiframe.js'

106 static files copied to '/home/docker/crypt/static'. Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 367, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 305, in run_from_argv self.execute(*args, *cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 356, in execute output = self.handle(args, options) File "/home/docker/crypt/server/management/commands/update_admin_user.py", line 43, in handle su_count = User.objects.filter(is_superuser=True).count() File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 369, in count return self.query.get_count(using=self.db) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 476, in get_count number = obj.get_aggregation(using, ['count'])['count'] File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 457, in get_aggregation result = compiler.execute_sql(SINGLE) File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 833, in execute_sql cursor = self.connection.cursor() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 233, in cursor cursor = self.make_cursor(self._cursor()) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 204, in _cursor self.ensure_connection() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in exit six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 199, in ensure_connection self.connect() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/base.py", line 171, in connect self.connection = self.get_new_connection(conn_params) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 209, in get_new_connection conn = Database.connect(conn_params) django.db.utils.OperationalError: unable to open database file 2017-04-06 11:53:13,083 CRIT Supervisor running as root (no user in config file) 2017-04-06 11:53:13,107 INFO RPC interface 'supervisor' initialized 2017-04-06 11:53:13,108 CRIT Server 'unix_http_server' running without any HTTP authentication checking 2017-04-06 11:53:13,108 INFO supervisord started with pid 18 2017-04-06 11:53:14,110 INFO spawned: 'nginx' with pid 21 2017-04-06 11:53:14,111 INFO spawned: 'gunicorn' with pid 22 2017-04-06 11:53:15,575 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2017-04-06 11:53:15,575 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

grahamgilbert commented 7 years ago

It doesn't even look like you connected the containers together. Please post the exact commands you issued.

tkojames24 commented 7 years ago

This are the commands I ran. Thank you for the help on this. I am hoping to get this to work as it would work perfectly for my needs.

sudo docker run -d --name="Crypt" \

--restart="always" \ -v /home/user/crypt:/home/docker/crypt/keyset \ -v /home/user/crypt:/home/docker/crypt/crypt.db \ -p 8000:8000 \ macadmins/crypt-server

grahamgilbert commented 7 years ago

Your volumes are wrong. You've linked the same directory on the host to a directory and a flat file.

More like:

sudo docker run -d --name="Crypt" \
--restart="always" \
-v /home/user/crypt/keyset:/home/docker/crypt/keyset \
-v /home/user/crypt/crypt.db:/home/docker/crypt/crypt.db \
-p 8000:8000 \
macadmins/crypt-server

Plus you are Yolo-ing the latest. I suggest strongly using a tagged release.