我已经构建了一个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,但试图访问该网址
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 OS: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]
流浪汉: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)访问您的VM"lucid32"
vagrant ssh
3)在VM中,配置Apache"虚拟主机":
ServerName your-domain.dev DocumentRoot /vagrant DirectoryIndex index.php index.html index.htm AllowOverride All Allow from All ServerName your-domain.dev DocumentRoot /vagrant DirectoryIndex index.php index.html index.htm AllowOverride All Allow from All SSLEngine on SSLCertificateFile /path/to/certicate/apache.pem
4)退出VM并在主机中配置文件"hosts":
33.33.33.10 your-domain.dev