django-socketio
django-socketio copied to clipboard
Please add to the docs: How to use behind Apache or NGINX
Up to now there is nothing about "apache" in the docs:
https://readthedocs.org/search/project/?q=apache&selected_facets=project_exact%3Adjango-socketio
Please add some information how it can be used with apache.
Do you need to open a new port, or is it possible to use the proxy module?
Thank you.
I was able to access django-socketio behind an Apache server. Here are the configuration steps I needed to perform to get it working.
- The Apache server and django-socketio server need to be configured with different ports. The Apache is configured with the standard HTTP ports of 80 and 443. django-socketio server is configured with a different port, such as 8080 or 8443.
- Setup Supervisor to run django-socketio as a service. I couldn't figure out how to setup it up using WSGI. So I execute the manage.py runserver_socketio command.
- Edit the Javascript code to so the Socket IO connects to the Apache server. Notice I added a secure option for SSL connections.
var socket = new io.Socket('{{ socketio_host }}', { port: {{ socketio_po
rt }}, secure: {{ socketio_secure }} });
- Update Apache to reverse proxy requests to the django_socketio server. The Apache server will need to have the mod_proxy module installed. Add the following two lines in the site's configuration file.
ProxyPass / http://my.server.com:8443/
ProxyPassReverse / http://my.server.com:8443/
@bytedreamer thank you for sharing!