python - how to configure django on apache and make https in the apache so that django url should open with https://<ip>:80 port -
i want django run on https server securely without using thirdparty packages runsslserver, or sslserver approach
in settings.py file have configured these line.
secure_ssl_redirect = true
so when giving url in browser url able redirect https://192.168.31.2/cp_vm/details i'm getting secure ssl error.
please suggest me ways output, or running django on apache https fine i'm able find links https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04 after giving ip in browser 192.168.41.5/cp_vm/details shows unable connect.
i'm attaching apache 000.default.conf file please me in this, pleas forgive me if mistakes in above kindly suggest me pointers
- i can run django on apache server first .
- then getting https// on same apache server. please provide me great if helping hands.
my config file follows:
<virtualhost *:80> # servername directive sets request scheme, hostname , port # server uses identify itself. used when creating # redirection urls. in context of virtual hosts, servername # specifies hostname must appear in request's host: header # match virtual host. default virtual host (this file) # value not decisive used last resort host regardless. # however, must set further virtual host explicitly. #servername www.example.com servername 10.206.51.6 serveradmin 10.206.51.6 #serveradmin webmaster@localhost #documentroot /var/www/html documentroot /var/www/nfvs_portal ## imc urls proxypass /imc http://10.206.50.12:8080/imc proxypassreverse /imc http://10.206.50.12:8080/imc <directory /var/www/html/> options indexes followsymlinks multiviews allowoverride none order allow,deny allow </directory> # available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # possible configure loglevel particular # modules, e.g. #loglevel info ssl:warn errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined # configuration files conf-available/, # enabled or disabled @ global level, possible # include line 1 particular virtual host. example # following line enables cgi configuration host # after has been globally disabled "a2disconf". #include conf-available/serve-cgi-bin.conf alias /static /opt/hpe_nfvs/nfvs_portal/static <directory /opt/hpe_nfvs/nfvs_portal/static> require granted </directory> <directory /opt/hpe_nfvs/nfvs_portal/nfvs_portal> <files wsgi.py> require granted </files> </directory> wsgidaemonprocess nfvs_portal python-path=//opt/hpe_nfvs/nfvs_portal:/opt/hpe_nfvs/nfvs_portal/nfvs_portal/lib/python2.7/site-packages wsgiscriptalias / /opt/hpe_nfvs/nfvs_portal/nfvs_portal/wsgi.py </virtualhost>
on top of http server, you need run ssl server apache2, i.e. configure <virtualhost *:443>
. also, let apache2 handle redirection instead of django.
<virtualhost *:80> # virtual host redirection servername 10.206.51.6 serveradmin 10.206.51.6 # <- should email! documentroot /dev/null/ redirect permanent / https://10.206.51.6/ # redirects after "/" </virtualhost> <virtualhost *:443> # ssl site servername 10.206.51.6 serveradmin 10.206.51.6 # <- should email! documentroot /var/www/nfvs_portal/ sslcertificatefile /etc/apache2/certs/your-server-certificate.pem sslcertificatekeyfile /etc/apache2/certs/your-server-certificate.key.pem # ... [the rest of site configuration] </virtualhost>
if trouble configuration, split problem in (1) making apache2 manage redirect , serve static ssl page in document root (without using wsgi), , (2) modify configuration use django site.
Comments
Post a Comment