I'm trying to configure the following setup:
- Django w/ channels
- Multiple Daphne processes as the ASGI server, with ssl endpoints
- Supervisor managing Daphne
- No other server (nginx, etc.) in front of Daphne
Without using ssl, I can bind all the Daphne processes to a single file descriptor and Supervisor will expose this as single endpoint.
This doesn't seem possible when using ssl endpoints unless I'm missing something.
My supervisord.conf looks like this:
[fcgi-program:daphne]
command=/usr/local/bin/daphne
-e ssl:port=8443:privateKey=/project/ssl/key.pem:certKey=/project/ssl/cert.pem
-u /tmp/daphne%(process_num)d.sock
--fd 0
myapp.asgi:application
directory=/project/src
numprocs=4
process_name=daphne%(process_num)d
socket=tcp://0.0.0.0:8000
When I bring up the server, however, it only listens to the first process, and I get this error for each of the n-1 additional processes that are spawned:
DEBG 'daphne1' stderr output:
INFO HTTPFactory starting on 8000
INFO Starting factory <daphne.http_protocol.HTTPFactory object at 0xffffa448db40>
INFO Listening on TCP address 0.0.0.0:8000
INFO Configuring endpoint ssl:port=8443:certKey=/project/ssl/cert.pem:privateKey=/project/ssl/key.pem
CRITICAL Listen failure: Couldn't listen on any:8443: [Errno 98] Address already in use.
INFO Configuring endpoint unix:/run/daphne1.sock
INFO HTTPFactory starting on '/run/daphne1.sock'
So basically, the processes start fine, but Daphne is itself grabbing the first tcp socket at 8443, and then nothing else can bind to it.
Is there anyway around this without running Daphne w/o ssl and putting a proxy server (nginx) in front of Supervisor to handle the ssl connection?