gpt4 book ai didi

ssl - 使用 ssl(端口转发)访问 vagrant 沙箱上的 apache

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

我构建了一个 vagrant/virtualbox web 服务器作为开发沙箱,并在 VM 中为 ssl 配置了 apache(在默认端口 443 上,带有自签名证书)。我已经使用 curl 测试了 VM 本身的页面

curl -v -k https://mysite.mydomain.com/testSearch/results?postcode=WN8+0BA

它似乎工作得非常愉快,所以我很满意 apache 已正确配置并在 VM 中工作。

但是,当我尝试通过 https 从主机的浏览器访问 VM 时,我无法这样做。

我已经添加了

config.vm.forward_port "https", 443, 8443

到我的 vagrantfile,但试图访问 url

https://mysite.mydomain.com:8443/testSearch/results?postcode=WN8+0BA

根本无法显示页面我试过几个不同的浏览器:IE给出了一个毫无意义的“Internet Explorer无法显示网页”; Chrome 给

SSL connection error
Unable to make a secure connection to the server. This may be a problem with the server or it may be requiring a client authentication certificate that you don't have.
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.

Firefox 给我

An error occurred during a connection to mysite.mydomain.com:8443.
SSL received a record that exceeded the maximum permissible length.
(Error code: ssl_error_rx_record_too_long)

但即使是 Firebug Net 选项卡也没有告诉我更多信息。

我在 VM apache 的访问日志或错误日志中没有得到任何信息,所以我怀疑 vagrant 根本没有转发 ssl。

  • VM guest 操作系统:centos56x64
  • 主机:Windows 7 64 位
  • JRuby:1.6.3 (ruby-1.8.7-p330) (2011-07-07 965162f)(Java HotSpot(TM) 64 位服务器 VM 1.6.0_24)[Windows 7-amd64-java]<
  • Vagrant :0.7.8
  • VirtualBox:4.0.12

如有任何帮助,我们将不胜感激。

最佳答案

1)配置文件Vagrantfile

Vagrant::Config.run do |config|
config.vm.box = "lucid32"
config.vm.network "33.33.33.10"
config.vm.forward_port "http", 80, 8080
end

2) 访问您的虚拟机“lucid32”

vagrant ssh

3) 在您的 VM 中,配置 Apache“虚拟主机”:

<VirtualHost 33.33.33.10:80>
ServerName your-domain.dev
DocumentRoot /vagrant
DirectoryIndex index.php index.html index.htm

<Directory /vagrant>
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

<VirtualHost 33.33.33.10:443>
ServerName your-domain.dev
DocumentRoot /vagrant
DirectoryIndex index.php index.html index.htm

<Directory /vagrant>
AllowOverride All
Allow from All
</Directory>

SSLEngine on
SSLCertificateFile /path/to/certicate/apache.pem
</VirtualHost>

4) 退出虚拟机并在主机中配置“hosts”文件:

33.33.33.10    your-domain.dev

关于ssl - 使用 ssl(端口转发)访问 vagrant 沙箱上的 apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7037497/

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