Closed yuidvg closed 1 week ago
webサーバーを使用しない場合の設定方法
Djangoの開発サーバー(runserver)ではなく、プロダクション環境向けのWSGIサーバー(Gunicornなど)を使用し、WSGIサーバー自体にSSL証明書を設定する
opensslで自己証明書を発行 yamlファイルにnetworkを明示していないので、デフォルトのnetworkが適用される =>inceptionのようにwebからのリクエストをhttps通信に設定すれば解決するのではないか
setting.pyで設定、gunicorn呼び出し時にcertfileを指定
appサーバーを切り替える python3 /app/backend/manage.py runserver 0.0.0.0:8000 --insecure
pip install gunicorn gunicorn --certfile=/path/to/fullchain.pem --keyfile=/path/to/privkey.pem --bind 0.0.0.0:443 myproject.wsgi:application
appサーバーをdjangoとした場合、httpsを実現するには、 ・Gunicornで実現 => 静的ファイルを提供しないため、frontend/は別サーバーを建てる必要がある ・開発用サーバーrunserverで実限 => runserverコマンドをオーバーライドする必要がある ・webサーバーを導入 => nginxが必要
色々試したところ、inceptionのようにnginxでhttps通信を実現するのが良さそう
ホストマシンからはhttps通信でポート443からしかアクセスできないようにする
from Subjects
III.4 Security concerns In order to create a basic functional website, here are a few security concerns that you have to tackle: • If you have a backend or any other features, it is mandatory to enable an HTTPS connection for all aspects (Utilize wss instead of ws...).
from Review Security concerns -Ensure that the website is secured. -Be carefull about TLS. If there is a backend or any other features, it must be available.