ImportError: No module named middleware.proxy_fix

Seems like an error introduced with a new update to CTFd. I’ve tried rebuilding with docker-compose up --force-recreate after git pull but I’m still getting this error.

What should I do to fix the issue?

I’m not sure if --force-recreate does what you want.

You should probably try docker-compose build --no-cache and docker-compose up. If this is still an issue you should check what version of Flask and Werkzeug are being installed. Both are already pinned to a specific version in CTFd so I don’t know what the issue could be.

After doing that, I’m getting this error:

ctfd_1   | [2020-02-19 18:12:19,073] ERROR in app: Exception on / [GET]
ctfd_1   | Traceback (most recent call last):
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
ctfd_1   |     response = self.full_dispatch_request()
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
ctfd_1   |     rv = self.handle_user_exception(e)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask_restplus/api.py", line 584, in error_router
ctfd_1   |     return original_handler(e)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
ctfd_1   |     reraise(exc_type, exc_value, tb)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
ctfd_1   |     raise value
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
ctfd_1   |     rv = self.dispatch_request()
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
ctfd_1   |     return self.view_functions[rule.endpoint](**req.view_args)
ctfd_1   |   File "/opt/CTFd/CTFd/views.py", line 313, in static_html
ctfd_1   |     return render_template("page.html", content=markdown(page.content))
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/templating.py", line 140, in render_template
ctfd_1   |     ctx.app,
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/templating.py", line 120, in _render
ctfd_1   |     rv = template.render(context)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
ctfd_1   |     self.environment.handle_exception()
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
ctfd_1   |     reraise(*rewrite_traceback_stack(source=source))
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
ctfd_1   |     raise value.with_traceback(tb)
ctfd_1   |   File "/opt/CTFd/CTFd/themes/hacker-theme/templates/page.html", line 1, in top-level template code
ctfd_1   |     {% extends "base.html" %}
ctfd_1   |   File "/opt/CTFd/CTFd/themes/hacker-theme/templates/base.html", line 33, in top-level template code
ctfd_1   |     <link rel="stylesheet" type="text/css" href="{{ url_for('views.custom_css') }}">
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/sandbox.py", line 462, in call
ctfd_1   |     return __context.call(__obj, *args, **kwargs)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/helpers.py", line 343, in url_for
ctfd_1   |     appctx.app.inject_url_defaults(endpoint, values)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2196, in inject_url_defaults
ctfd_1   |     func(endpoint, values)
ctfd_1   |   File "/opt/CTFd/CTFd/utils/initialization/__init__.py", line 147, in inject_theme
ctfd_1   |     endpoint, "theme"
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/werkzeug/routing.py", line 1377, in is_endpoint_expecting
ctfd_1   |     for rule in self._rules_by_endpoint[endpoint]:
ctfd_1   | KeyError: 'views.custom_css'
ctfd_1   | [2020-02-19 18:12:19 +0000] [19] [ERROR] Error handling request /
ctfd_1   | Traceback (most recent call last):
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
ctfd_1   |     response = self.full_dispatch_request()
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
ctfd_1   |     rv = self.handle_user_exception(e)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask_restplus/api.py", line 584, in error_router
ctfd_1   |     return original_handler(e)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
ctfd_1   |     reraise(exc_type, exc_value, tb)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
ctfd_1   |     raise value
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
ctfd_1   |     rv = self.dispatch_request()
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
ctfd_1   |     return self.view_functions[rule.endpoint](**req.view_args)
ctfd_1   |   File "/opt/CTFd/CTFd/views.py", line 313, in static_html
ctfd_1   |     return render_template("page.html", content=markdown(page.content))
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/templating.py", line 140, in render_template
ctfd_1   |     ctx.app,
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/templating.py", line 120, in _render
ctfd_1   |     rv = template.render(context)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
ctfd_1   |     self.environment.handle_exception()
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
ctfd_1   |     reraise(*rewrite_traceback_stack(source=source))
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
ctfd_1   |     raise value.with_traceback(tb)
ctfd_1   |   File "/opt/CTFd/CTFd/themes/hacker-theme/templates/page.html", line 1, in top-level template code
ctfd_1   |     {% extends "base.html" %}
ctfd_1   |   File "/opt/CTFd/CTFd/themes/hacker-theme/templates/base.html", line 33, in top-level template code
ctfd_1   |     <link rel="stylesheet" type="text/css" href="{{ url_for('views.custom_css') }}">
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/sandbox.py", line 462, in call
ctfd_1   |     return __context.call(__obj, *args, **kwargs)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/helpers.py", line 343, in url_for
ctfd_1   |     appctx.app.inject_url_defaults(endpoint, values)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2196, in inject_url_defaults
ctfd_1   |     func(endpoint, values)
ctfd_1   |   File "/opt/CTFd/CTFd/utils/initialization/__init__.py", line 147, in inject_theme
ctfd_1   |     endpoint, "theme"
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/werkzeug/routing.py", line 1377, in is_endpoint_expecting
ctfd_1   |     for rule in self._rules_by_endpoint[endpoint]:
ctfd_1   | KeyError: 'views.custom_css'
ctfd_1   |
ctfd_1   | During handling of the above exception, another exception occurred:
ctfd_1   |
ctfd_1   | Traceback (most recent call last):
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 56, in handle
ctfd_1   |     self.handle_request(listener_name, req, client, addr)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/ggevent.py", line 160, in handle_request
ctfd_1   |     addr)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 107, in handle_request
ctfd_1   |     respiter = self.wsgi(environ, resp.start_response)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
ctfd_1   |     return self.wsgi_app(environ, start_response)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
ctfd_1   |     response = self.handle_exception(e)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask_restplus/api.py", line 584, in error_router
ctfd_1   |     return original_handler(e)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1878, in handle_exception
ctfd_1   |     server_error = handler(server_error)
ctfd_1   |   File "/opt/CTFd/CTFd/errors.py", line 16, in general_error
ctfd_1   |     return render_template("errors/500.html"), 500
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/templating.py", line 140, in render_template
ctfd_1   |     ctx.app,
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/templating.py", line 120, in _render
ctfd_1   |     rv = template.render(context)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1090, in render
ctfd_1   |     self.environment.handle_exception()
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
ctfd_1   |     reraise(*rewrite_traceback_stack(source=source))
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
ctfd_1   |     raise value.with_traceback(tb)
ctfd_1   |   File "/opt/CTFd/CTFd/themes/hacker-theme/templates/errors/500.html", line 1, in top-level template code
ctfd_1   |     {% extends "base.html" %}
ctfd_1   |   File "/opt/CTFd/CTFd/themes/hacker-theme/templates/base.html", line 33, in top-level template code
ctfd_1   |     <link rel="stylesheet" type="text/css" href="{{ url_for('views.custom_css') }}">
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/jinja2/sandbox.py", line 462, in call
ctfd_1   |     return __context.call(__obj, *args, **kwargs)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/helpers.py", line 343, in url_for
ctfd_1   |     appctx.app.inject_url_defaults(endpoint, values)
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2196, in inject_url_defaults
ctfd_1   |     func(endpoint, values)
ctfd_1   |   File "/opt/CTFd/CTFd/utils/initialization/__init__.py", line 147, in inject_theme
ctfd_1   |     endpoint, "theme"
ctfd_1   |   File "/usr/local/lib/python3.7/site-packages/werkzeug/routing.py", line 1377, in is_endpoint_expecting
ctfd_1   |     for rule in self._rules_by_endpoint[endpoint]:

Here is my requirements.txt:

Flask==1.1.1
Werkzeug==0.16.0
Flask-SQLAlchemy==2.4.1
Flask-Caching==1.4.0
Flask-Migrate==2.5.2
Flask-Script==2.0.6
SQLAlchemy==1.3.11
SQLAlchemy-Utils==0.36.0
passlib==1.7.2
bcrypt==3.1.7
six==1.13.0
itsdangerous==1.1.0
requests>=2.20.0
PyMySQL==0.9.3
gunicorn==19.9.0
normality==2.0.0
dataset==1.1.2
mistune==0.8.4
netaddr==0.7.19
redis==3.3.11
datafreeze==0.1.0
gevent==1.4.0
python-dotenv==0.10.3
flask-restplus==0.13.0
pathlib2==2.3.5
flask-marshmallow==0.10.1
marshmallow-sqlalchemy==0.17.0
boto3==1.10.39
marshmallow==2.20.2

It looks like you have a custom theme that’s referencing the old views.custom_css endpoint. If it’s an official theme we just sent out updates for CTFd v2.3.0 compatibility.

That was the issue! Thanks!