如何让网站的一部分不在web2py中使用https?

时间:2015-01-23 18:51:34

标签: python apache https ssl-certificate web2py

标准的web2py部署示例要求https在整个网站范围内使用。如何在某些页面上跳过它,或者最好只在管理界面上使用它?在某些页面上,我需要提供来自第三方服务器的一些内容,而且这些内容不安全,我无能为力。

我当前为我的网站配置的apache是​​:

<VirtualHost *:80>
  ServerName mywebsite.com
  ServerAlias mywebsitealias.com
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

  CustomLog /var/log/apache2/access.log common
  ErrorLog /var/log/apache2/error.log
</VirtualHost>

<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl/self_signed.cert
  SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key

  WSGIProcessGroup web2py
  WSGIScriptAlias / /var/www/web2py/wsgihandler.py
  WSGIPassAuthorization On

  <Directory /var/www/web2py>
    AllowOverride None
    Require all denied
    <Files wsgihandler.py>
      Require all granted
    </Files>
  </Directory>

  AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
        /var/www/web2py/applications/$1/static/$2

  <Directory /var/www/web2py/applications/*/static/>
    Options -Indexes
    ExpiresActive On
    ExpiresDefault "access plus 1 hour"
    Require all granted
  </Directory>

  CustomLog /var/log/apache2/ssl-access.log common
  ErrorLog /var/log/apache2/error.log
</VirtualHost>

1 个答案:

答案 0 :(得分:0)

我设法通过替换VirtualHost *:80 ... / VirtualHost来实现它   请使用下面的代码:

<VirtualHost *:80>

 WSGIProcessGroup web2py
  WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
  WSGIPassAuthorization On

  <Directory /home/www-data/web2py>
    AllowOverride None
    Require all denied
    <Files wsgihandler.py>
      Require all granted
    </Files>
  </Directory>

  CustomLog /var/log/apache2/access.log common
  ErrorLog /var/log/apache2/error.log
</VirtualHost>

http:那些曾经与Apache 2.2一起工作的东西,然后当Apache升级到2.4时,安装脚本的改变方式使得所有内容都成为https。上面是我对这两个脚本的混搭,虽然我不确定它是否有任何故障,但似乎对我有用。