ホストマシン(Windows 10)にバゲント(Ubuntu 14.04)でホストされているテストサイトを表示する方法を教えてください。私はUbuntuの上カールlocalhost.ng:81をやろうとしているとき、私はそれがnginxのデフォルトページが表示されますが表示さlocalhost.ng:81またはlocalhost.ngにアクセスしようとすることができます。 8100私のホストマシン(Windows)に表示されますこのウェブページは利用できません以下は私の構成があるホストマシンがポート81のVagrant(nginx)と通信できません
のWindows etc/hostsファイルをファイル:
192.168.0.25 localhost.ng
ベイグラントファイルのネットワークの設定:
config.vm.network "forwarded_port", guest: 81, host: 8100
config.vm.network "private_network", ip: "192.168.0.25"
config.vm.network "public_network"
nginxのバーチャルホストの設定:
server {
listen 81 default_server;
listen [::]:81 default_server ipv6only=on;
root /development/nginx/sites;
index index.php index.html index.htm;
server_name localhost.ng;
location/{
try_files $uri $uri/ =404;
autoindex on;
}
#error_page 404 /404.html;
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
#root /development/nginx/sites;
#}
location ~ \.php$ {
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
の/ etc/hostsの設定:
127.0.0.1 localhost
127.0.0.2 localhost.ng
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
127.0.1.1 developer developer
の
ログ:
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
default: Adapter 3: bridged
==> default: Forwarding ports...
default: 81 (guest) => 8100 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
ファイル/開発/ nginxの/サイトの下には777モードを設定し、WWWによって所有されています。このため、データは単なるテストのためです。
確かに、あなたのホストマシンと同じ値を持つ 'private_network' IPアドレスを設定すべきではありません。あなたは同じIPを持つ2台のマシンで終わります。これがポート転送を妨げるかどうかは分かりにくいですが、そのような場合はランダムに動作する可能性があります。 – techraf
@techrafありがとう、私は自分の仮想マシンで使用しているIPが自分のホストマシンのIP範囲にないことを知りました。 – PenAndPapers