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

发布于 2025-01-07 19:35:08 字数 247 浏览 0 评论 0原文

我的网站有一个 SSL 文件夹以及一个非 SSL 部分。

如果我在 SSL 文件夹中,引用 SSL“包装器”之外的任何不安全图像,就会在 FF 中显示“您正在查看的页面的部分内容在通过 Internet 传输之前未加密”。预期的。

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

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

I have an SSL folder as well as a non SSL part to my site.

If I'm in my SSL folder, referencing any insecure images outside the SSL 'wrapper' gives me the "Parts of the page you are viewing were not encrypted before being transmitted over the Internet" in FF. Expected.

The way I would usually deal with this issue, is to make a copy of my images folder within the SSL folder. But that could turn out to be an admin nightmare becuase I have two sets of images to update.

Is it possible to reference content by using a different method? Perhaps using PHP's document root? What is the recommended method?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情何以堪。 2025-01-14 19:35:08

符号链接

如果您使用的是 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 的访问都从同一文档根目录访问文件。

将您的虚拟主机配置更改为:

# 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>

然后创建 /etc/apache2/server-vhost.conf,如上面两个虚拟主机配置中的 Include 行所引用:

ServerName example.org
ServerAdmin [email protected]
DocumentRoot /var/www/vhosts/example.org/httpdoc

Symlink

If you are on a linux box then you can use a symlink to alias all the entire httpdocs folder to the https directory.

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

This is described as

ln -s source_file link_name

This way everything that is in httpdocs is available to the server via httpsdocs as well without copying anything. Obviously if you do not wish to symlink the whole lot you could just symlink your images directory.

You can use this on a box where you are unable to update the virtual host container.

Change the virtual host configuration

This will of course cause all access to both http and https to access the files from the same document root directory.

Change you vhost configuration to be:

# 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>

Then create /etc/apache2/server-vhost.conf as referenced by the Include lines in the two vhost configurations above:

ServerName example.org
ServerAdmin [email protected]
DocumentRoot /var/www/vhosts/example.org/httpdoc
夜光 2025-01-14 19:35:08

您可以使用图像的相对路径。在他的例子中,将使用与页面本身相同的协议来请求图片,HTTPS 页面使用 HTTPS,HTTP 页面使用 HTTP。

编辑:

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

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

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

You could use relative path's to your images. In his case the pictures will be requested with the same protocol as the page itself, HTTPS for a HTTPS-page and HTTP for a HTTP-page.

Edit:

Since we don't know about the directory structure, i add a small example of what i mean.

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

If we have a file root/http/index.html and a picture in root/img/button.png, we can use the relative path ../img/button.png, this will work whether the page is in the http or in the https subdirectory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文