【问题标题】:How to enable SSL for a whole django site with apache2+ubuntu 11?如何使用 apache2+ubuntu 11 为整个 django 站点启用 SSL?
【发布时间】:2012-06-22 06:44:29
【问题描述】:

我需要为我的整个 django 站点之一启用 SSL。目前,该站点由 Ubuntu 11.1 中的 Apache2 托管,只能通过 http 访问。我想知道以下内容,

1) 为该站点启用 ssl 的 Apache 配置。

2) Django 相关的相同更改,如果有的话。

Another question of the same kind 无人回答,所以再次在这里询问。

【问题讨论】:

    标签: django ssl https apache2 ubuntu-11.10


    【解决方案1】:

    你可以像这样调整你的 apache 配置来做到这一点:

    # Turn on Rewriting
    RewriteEngine on 
    
    # Apply this rule If request does not arrive on port 443
    RewriteCond %{SERVER_PORT} !443 
    
    # RegEx to capture request, URL to send it to (tacking on the captured text, stored in $1), Redirect it, and Oh, I'm the last rule.
    RewriteRule ^(.*)$ https://www.x.com/dir/$1 [R,L]
    

    请注意,这取自https://serverfault.com/questions/77831/how-to-force-ssl-https-on-apache-location

    django 不应该有任何必要的更改。 HTH。

    【讨论】:

    • 谢谢!这会有所帮助。尝试后将答案标记为正确。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-31
    • 2019-07-04
    • 2018-11-10
    • 1970-01-01
    • 2021-06-10
    • 2014-08-28
    • 2012-05-10
    相关资源
    最近更新 更多