lduarte1991 / hxat

Contains the currently-in-development project by HarvardX to bring the annotation tool currently living in the edX platform to a more accessible LTI implementation.
13 stars 7 forks source link

Daphne + SSL + WhiteNoise for local development #134

Closed arthurian closed 3 years ago

arthurian commented 3 years ago

This PR adds support for running an SSL development server using Daphne + WhiteNoise.

Changes:

Additional Notes:

The problem this PR is solving is that django-sslserver does not support ASGI/Daphne, and while the default runserver command does support ASGI/Daphne, it does not support SSL (or at least it does not provide a way to configure daphne -- which would obviate the need for this PR).

One way to handle this is to run 2 processes: daphne to handle websocket requests, and django-sslserver to handle everything else, including static files. For example:

$ ./manage.py runsslserver --key key.pem --certificate cert.pem 127.0.0.1:8000
$ daphne -e ssl:8001:privateKey=key.pem:certKey=cert.pem annotationsx.asgi:application

But when we do this, we also have to configure the wsUrl in the hxighlighter templates to point to a different port than the main application. It would be simpler if we could have daphne handle everything, including staticfiles:

$ daphne -e ssl:8000:privateKey=key.pem:certKey=cert.pem annotationsx.asgi:application

This is the approach taken by the PR. If there's a better way, definitely open to it!

@nmaekawa Thoughts?