gpt4 book ai didi

django - 如何使用 apache2+ubuntu 11 为整个 django 站点启用 SSL?

转载 作者:太空宇宙 更新时间:2023-11-03 13:28:58 24 4
gpt4 key购买 nike

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

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

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

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

最佳答案

您可以像这样调整您的 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.

关于django - 如何使用 apache2+ubuntu 11 为整个 django 站点启用 SSL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11151336/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com