基于Django的框架虚拟主机设置https在Apache上

时间:2013-03-26 01:12:42

标签: django https apache2 mod-wsgi django-wsgi

我正在使用基于django的框架,并成功为http模式设计了Apache设置。基本上我已经在<VirtualHost *:80> ... </VirtualHost>上正确完成了设置,当我这样做时,http://mysite.domain.com我正确地路由到我的网站,网站页面和皮肤得到正确渲染。

我已经设置https://mysite.domain.com与shibboleth一起使用,shibboleth正在工作,当使用https我通过shibboleth服务器路由到登录凭据页面,并且在成功登录后我被重定向到https://mysite.domain.com但是网站没有正确呈现,并且外观不会显示为与http://mysite.domain.com相同。

这是我的Apache设置,我试图了解我在这里做错了什么

<VirtualHost *:443>
     ServerAdmin myname@mydomain.com
     DocumentRoot /code/vEnviornment/mysite
     ServerName mydomain.com
     #<LocationMatch "^(?!/admin)">
     #<LocationMatch "^(?!/m)">
     #    RewriteEngine on
     #    RewriteRule django.wsgi(.*)$ https://mydomain.com:443$1 [L,R=301]
     #</LocationMatch>
     SSLEngine on
     #your SSL keys
     #I have removed this wasn't comfortable putting SSL key info
     #Alias /admin/media/ /usr/local/lib/python2.6/site-packages/django/contrib/admin/media/
     Alias /admin/media/ /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/
     WSGIScriptAlias /m/ /code/vEnviornment/mysite/django.wsgi
     <Directory "/">
     AuthType shibboleth
     ShibRequestSetting requireSession 1
     Require valid-user
     </Directory>
     Alias /Shibboleth.sso /tmp
     #    CustomLog /var/log/httpd/mysite/access_log common
     #    ErrorLog /var/log/httpd/mysite/error_log
    CustomLog /var/log/apache2/mysite/access_log common
    ErrorLog /var/log/apache2/mysite/error_log
</VirtualHost>

以下是我的hetup http:

<VirtualHost *:80>
     ServerAdmin myname@mydomain.com
     DocumentRoot /code/vEnviornment/mysite
     ServerName mysite.mydomain.com

     #aliases to serve static media directly
     #will probably need adjustment
     Alias /m/ /code/vEnviornment/mysite/static/
     Alias /upfiles/ /code/vEnviornment/mysite/myframework/upfiles/
     <DirectoryMatch "/code/vEnviornment/mysite/myframework/skins/([^/]+)/media">
        Order deny,allow
        Allow from all
     </DirectoryMatch>
     <Directory "/code/vEnviornment/mysite/myframework/upfiles">
        Order deny,allow
        Allow from all
     </Directory>
     #must be a distinct name within your apache configuration
     WSGIDaemonProcess mysite2
     WSGIProcessGroup mysite2
     WSGIScriptAlias / /code/vEnviornment/mysite/django.wsgi
     #make all admin stuff except media go through secure connection
     <LocationMatch "/admin(?!/media)">
     RewriteEngine on
         RewriteRule /admin(.*)$ https://128.101.35.71/admin$1 [L,R=301]
     </LocationMatch>
    # CustomLog /var/log/httpd/mysite/access_log common
    # ErrorLog /var/log/httpd/mysite/error_log
    CustomLog /var/log/apache2/mysite/access_log common
    ErrorLog /var/log/apache2/mysite/error_log
    LogLevel debug
</VirtualHost>

我在这里做错了是通过 https?

错误地渲染网站

1 个答案:

答案 0 :(得分:0)

Alias /m/ /code/vEnviornment/mysite/static/
 Alias /upfiles/ /code/vEnviornment/mysite/myframework/upfiles/

https虚拟主机

中缺少这两行

您的WSGIScriptAlias应指向/ not / m /