1

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

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

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

另一个同类型的问题没有答案,所以再次在这里问。

4

1 回答 1

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。

于 2012-06-22T11:15:17.947 回答