Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable secure websocket for secure sites #102

Merged
merged 2 commits into from
Mar 23, 2021

Conversation

fmalina
Copy link
Contributor

@fmalina fmalina commented Mar 8, 2021

Enhancement

Description

This enables secure websocket for secure sites

Fixes # (issue)

Why should this be added

An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

Checklist

  • Tests are passing
  • Documentation has been added or amended for this feature / update

@fmalina fmalina changed the title Enable secure websocket for secure sites WIP Enable secure websocket for secure sites Mar 8, 2021
@fmalina fmalina changed the title WIP Enable secure websocket for secure sites WIP: Enable secure websocket for secure sites Mar 8, 2021
@fmalina fmalina changed the title WIP: Enable secure websocket for secure sites Enable secure websocket for secure sites Mar 8, 2021
@fmalina
Copy link
Contributor Author

fmalina commented Mar 8, 2021

Well actually that's it, the only other changes I had to do was adding websocket support to nginx config, install uvicorn and use its worker class from systemd and then update asgi.py

This could serve as example production deployment docs:

Nginx websocket support to add to server config (with certbot enabled)

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Install uvicorn

sudo apt get install uvicorn[standard]

Run uvicorn like so from systemd service file via ExecStart=

gunicorn asgi:application -k uvicorn.workers.UvicornWorker ...

asgi.py

import os
import django
from channels.routing import get_default_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'gama.settings')
django.setup()
application = get_default_application()

Not sure what's wrong with tests, could you help me with that?

@jonathan-s
Copy link
Owner

@fmalina Thanks for this PR! Now it's merged!

@jonathan-s jonathan-s merged commit 1813c6d into jonathan-s:master Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants