0

Following this guide https://medium.com/@elspanishgeek/how-to-deploy-django-channels-2-x-on-aws-elastic-beanstalk-8621771d4ff0 to set up a django project that uses websockets. Before I made the traffic go through Daphne, the static files were being served, but now I get on the console that the files are not found.

01_env.config

option_settings:  
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: dashboard.settings
    PYTHONPATH: /opt/python/current/app/dashboard:$PYTHONPATH
  aws:elasticbeanstalk:container:python:
    WSGIPath: dashboard/wsgi.py
  "aws:elasticbeanstalk:container:python:staticfiles":
      /static/: "static/"

  aws:elbv2:listener:80:
    ListenerEnabled: 'true'
    Protocol: HTTP
  aws:elbv2:listener:5000:
    ListenerEnabled: 'true'
    Protocol: HTTP

02_setup.config

container_commands:
  00_pip_upgrade:
    command: "source /opt/python/run/venv/bin/activate && pip install --upgrade pip"
    ignoreErrors: false
  01_migrate:
    command: "django-admin.py migrate"
    leader_only: true
  02_collectstatic:
    command: "django-admin.py collectstatic --noinput"
  03_wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'
  04_celery_tasks:
    command: "cat .ebextensions/celery_configuration.txt > /opt/elasticbeanstalk/hooks/appdeploy/post/run_supervised_celeryd.sh && chmod 744 /opt/elasticbeanstalk/hooks/appdeploy/post/run_supervised_celeryd.sh"
    leader_only: true
  05_celery_tasks_run:
    command: "/opt/elasticbeanstalk/hooks/appdeploy/post/run_supervised_celeryd.sh"
    leader_only: true

03_proxy.config

files:
  "/etc/httpd/conf.d/proxy.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      ProxyPass /websockets/ ws://127.0.0.1:5000/websockets/
      ProxyPassReverse /websockets/ ws://127.0.0.1:5000/websockets/
      ProxyPass / http://127.0.0.1:5000/
      ProxyPassReverse / http://127.0.0.1:5000/

settings.py

...

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

Running Daphne using:

daphne -b 0.0.0.0 -p 5000 dashboard.asgi:application
Filipe Aleixo
  • 3,924
  • 3
  • 41
  • 74

0 Answers0