14

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

いくつかの異なるブラウザーで試したページを単に表示できません。クロムは与える

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 ゲスト OS: centos56x64
  • ホスト: Windows 7 64 ビット
  • JRuby: 1.6.3 (ruby-1.8.7-p330) (2011-07-07 965162f) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [Windows 7-amd64-java]
  • 浮浪者: 0.7.8
  • バーチャルボックス: 4.0.12

どんな援助もありがたく受け入れます。

4

2 に答える 2

24

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 の「仮想ホスト」を構成します。

<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) VM を終了し、ホスト マシンでファイル「hosts」を構成します。

33.33.33.10    your-domain.dev
于 2011-11-15T00:15:04.303 に答える
0

上記の答えでは、ボックスを破壊するたびにステップ 2 と 3 を繰り返し続ける必要があります。Chef を使用して目標を達成することをお勧めします。以下の例を参照してください。

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

    config.vm.box       = "precise64"
    config.vm.box_url   = "http://files.vagrantup.com/precise64.box"

    config.vm.network :forwarded_port, guest: 80, host: 8080
    config.vm.network :forwarded_port, guest: 443, host: 443

    config.vm.network "private_network", ip: "192.168.33.10"

    config.vm.provision :chef_solo do |chef|

        chef.cookbooks_path = "/path/to/your/cookbooks"

        # Install PHP
        chef.add_recipe "php"
        chef.add_recipe "php::module_mysql"

        # Setup Apache
        chef.add_recipe "apache2"
        chef.add_recipe "apache2::mod_php5"

        chef.json = { :apache => { :default_site_enabled => true } }

    end

end
于 2015-02-26T14:01:34.870 に答える