SSL文件夹-访问不安全的内容


SSL Folder - access insecure content

我的站点有一个SSL文件夹和一个非SSL部分。

如果我在SSL文件夹中,引用SSL"包装器"之外的任何不安全图像会在FF中显示"您正在查看的页面的部分在通过互联网传输之前没有加密"。应为。

我通常处理这个问题的方法是在SSL文件夹中复制我的图像文件夹。但这可能会成为管理员的噩梦,因为我有两组图像要更新。

是否可以使用不同的方法引用内容?也许使用PHP的文档根目录?推荐的方法是什么?

Symlink

如果您使用的是linux系统,则可以使用符号链接将整个httpdocs文件夹别名为https目录。

ln -s /var/www/vhosts/example.org/httpdoc /var/www/vhosts/example.org/httpsdoc

这被称为

ln -s source_file link_name

这样,httpdocs中的所有内容都可以通过httpsdocs提供给服务器,而无需复制任何内容。显然,如果你不想符号链接整个地段,你可以只是符号链接你的图像目录。

您可以在无法更新虚拟主机容器的框中使用此选项。

更改虚拟主机配置

这当然会导致所有对http和https的访问都访问来自同一文档根目录的文件。

将您的vhost配置更改为:

# Virtual Hosting
<VirtualHost *:80>
    <IfModule mod_ssl.c>
        SSLEngine off
    </IfModule>
    Include /etc/apache2/server-vhost.conf
</VirtualHost>

# SSL Virtual Hosting
<VirtualHost *:443>
    <IfModule mod_ssl.c>
        SSLEngine on
        SSLOptions +StrictRequire
        SSLCertificateFile /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
    </IfModule>
    Include /etc/apache2/server-vhost.conf
</VirtualHost>

然后创建上面两个vhost配置中Include行引用的/etc/apache2/server-vhost.conf

ServerName example.org
ServerAdmin example@example.org
DocumentRoot /var/www/vhosts/example.org/httpdoc

您可以使用图像的相对路径。在他的情况下,图片将使用与页面本身相同的协议进行请求,HTTPS用于HTTPS页面,HTTP用于HTTP页面。

编辑:

由于我们不知道目录结构,我添加了一个小例子来说明我的意思。

root/http/index.html
root/https/index.html
root/img/button.png

如果我们在root/img/button.png中有一个文件root/http/index.html和一张图片,我们可以使用相对路径../img/button.png,无论页面是在http子目录中还是在https子目录中,这都会起作用。