<Django 側の設定>
・settings
・settings.py に追記
CERT_ROOT = os.path.join(BASE_DIR, '.well-known')
CERT_URL = '/.well-known/'
ALLOWED_HOSTS = ['www.[取得したドメイン]','[取得したドメイン]']
CERT_ROOT = os.path.join(BASE_DIR, '.well-known')
CERT_URL = '/.well-known/'
ALLOWED_HOSTS = ['www.[取得したドメイン]','[取得したドメイン]']
・urls.py に追記
from django.conf.urls.static import static
from django.conf import settings
urlpatterns += static(settings.CERT_URL, document_root=settings.CERT_ROOT)
from django.conf.urls.static import static
from django.conf import settings
urlpatterns += static(settings.CERT_URL, document_root=settings.CERT_ROOT)
・テスト用の静的ファイルを作成
/var/www/cgi-bin/***/---/.well-known/acme-challenge/test.html
/var/www/cgi-bin/***/---/.well-known/acme-challenge/test.html
(WEBブラウザにて表示されています)
*
*** → Django Project name
--- → Django app name
<証明書発行時コマンド>
certbot certonly --webroot -w /var/www/cgi-bin/***/---/.well-known/ -d [取得したドメイン wwwなし] --email=[メールアドレス]
certbot certonly --webroot -w /var/www/cgi-bin/***/---/.well-known/ -d [取得したドメイン wwwなし] --email=[メールアドレス]
<DNSの設定>
A(通常) @ TTL 3600 [IP-Adress]
A(通常) www TTL 3600 [IP-Adress]
NS @ TTL 3600 ns-a1.conoha.io
NS @ TTL 3600 ns-a2.conoha.io
NS @ TTL 3600 ns-a3.conoha.io
A(通常) @ TTL 3600 [IP-Adress]
A(通常) www TTL 3600 [IP-Adress]
NS @ TTL 3600 ns-a1.conoha.io
NS @ TTL 3600 ns-a2.conoha.io
NS @ TTL 3600 ns-a3.conoha.io
<Apache<Apache .conf>
LoadModule wsgi_module /usr/lib64/python3.6/site- packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
WSGIPythonPath /var/www/cgi-bin/***>
LoadModule wsgi_module /usr/lib64/python3.6/site- packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
WSGIPythonPath /var/www/cgi-bin/***
WSGIScriptAlias / /var/www/cgi-bin/***/***/wsgi.py
Alias /static/ /var/www/cgi-bin/***/---/static/
<Directory //var/www/cgi-bin/***/***/wsgi.py>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /var/www/cgi-bin/***/---/static>
Require all granted
</Directory>
<Apache ssl.conf> 最終行に追記
Alias /.well-known/acme-challenge/ /var/www/cgi-bin/***/---/.well- known/acme-challenge/
<location .well-known="">
Options -Indexes
Alias /.well-known/acme-challenge/ /var/www/cgi-bin/***/---/.well- known/acme-challenge/
<location .well-known="">
Options -Indexes
</location>