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

时间:2022-10-06 09:50:00

I need to enable SSL for one of my entire django site. Currently the site is hosted with Apache2 in Ubuntu 11.1 and just accessible through http. I'd like to know the following,

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

1) Apache configuration for enabling ssl for this site.

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

2) Django related changes of the same, if any.

2)Django相关的变化,如果有的话。

Another question of the same kind is unanswered, so asking here again.

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

1 个解决方案

#1


1  

You may do it by adjusting your apache config like this:

您可以通过调整您的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]

Note that this is taken from https://serverfault.com/questions/77831/how-to-force-ssl-https-on-apache-location.

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

There shouldnt be any changes necessary for django. HTH.

django不需要进行任何更改。 HTH。

#1


1  

You may do it by adjusting your apache config like this:

您可以通过调整您的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]

Note that this is taken from https://serverfault.com/questions/77831/how-to-force-ssl-https-on-apache-location.

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

There shouldnt be any changes necessary for django. HTH.

django不需要进行任何更改。 HTH。