Npm servieren von vagrant machineand windows host

551
Andrea Nisticò

Ich versuche, von einem Vagrant-Rechner aus zu dienen, der überbrückt ist, und ich möchte von jedem mit diesem öffentlichen Netzwerk verbundenen Gerät auf die Webseite zugreifen (zu experimentellen Zwecken). Ich greife auf die Maschine mit zuvagrant ssh

Das Problem ist, dass ich, wenn ich serve -s buildvon der Maschine aus laufe, Folgendes sehen kann:

 Serving!  - Local: http://localhost:5000  - On Your Network: http://127.0.0.1:5000 

was seltsam ist, weil "in Ihrem Netzwerk" das öffentliche Netzwerk anzeigen sollte, mit dem ich verbunden bin (?)

Meine Vagrant-Datei ist folgende:

Vagrant.configure("2") do |config|  config.vm.box = "generic/ubuntu1804" config.vm.network "public_network"  config.vm.synced_folder "./shared", "/home/vagrant/shared", owner: "vagrant", create: true, nfs: true, nfs_udp: false  config.vm.provider "virtualbox" do |v| host = RbConfig::CONFIG['host_os']  # Setup hardware config, host-os specific. Your host should have at least 6GB memory if host =~ /darwin/ # mac cpus = `sysctl -n hw.ncpu`.to_i # sysctl returns Bytes and we need to convert to MB # mem = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 2 mem = 10000 elsif host =~ /linux/ # linux cpus = `nproc`.to_i # meminfo shows KB and we need to convert to MB # mem = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / 4 mem = 10000 else # windows cpus = 2 mem = 10000 end v.customize ["modifyvm", :id, "--nictype1", "virtio"] v.customize ["modifyvm", :id, "--memory", mem] v.customize ["modifyvm", :id, "--cpus", cpus] v.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 1000] v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] end  # React server config.vm.network :forwarded_port, guest: 3000, host: 3000 config.vm.network :forwarded_port, guest: 5000, host: 5000  # Webpack server config.vm.network :forwarded_port, guest: 8000, host: 8000  # Eth node config.vm.network :forwarded_port, guest: 8545, host: 8545  # IPFS config.vm.network :forwarded_port, guest: 4001, host: 4001 config.vm.network :forwarded_port, guest: 5001, host: 5001 config.vm.network :forwarded_port, guest: 8080, host: 8080  config.vm.provision :shell, path: "bootstrap.sh" end 

Und wenn ich anfange, vagrant upbekomme ich:

$ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Checking if box 'generic/ubuntu1804' is up to date... ==> 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: bridged ==> default: Forwarding ports... default: 3000 (guest) => 3000 (host) (adapter 1) default: 5000 (guest) => 5000 (host) (adapter 1) default: 8000 (guest) => 8000 (host) (adapter 1) default: 8545 (guest) => 8545 (host) (adapter 1) default: 4001 (guest) => 4001 (host) (adapter 1) default: 5001 (guest) => 5001 (host) (adapter 1) default: 8080 (guest) => 8080 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key ==> default: Machine booted and ready! [default] GuestAdditions 5.2.16 running --- OK. ==> default: Checking for guest additions in VM... ==> default: Configuring and enabling network interfaces... ==> default: Mounting shared folders... default: /home/vagrant/shared => D:/Devel/Vagrant/VagrantTest/shared ==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> default: flag to force provisioning. Provisioners marked to run always will still run. 

während ifconfigzeigt:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe80::a00:27ff:fe2a:6801 prefixlen 64 scopeid 0x20<link> ether 08:00:27:2a:68:01 txqueuelen 1000 (Ethernet) RX packets 1371 bytes 611042 (611.0 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 860 bytes 98984 (98.9 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.20.41.109 netmask 255.255.255.0 broadcast 172.20.41.255 inet6 fe80::a00:27ff:fe12:4c8 prefixlen 64 scopeid 0x20<link> ether 08:00:27:12:04:c8 txqueuelen 1000 (Ethernet) RX packets 1310 bytes 330793 (330.7 KB) RX errors 0 dropped 68 overruns 0 frame 0 TX packets 38 bytes 5349 (5.3 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0  lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 1000 (Local Loopback) RX packets 196 bytes 16340 (16.3 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 196 bytes 16340 (16.3 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

Ich möchte also auf dienen eth1damit die ip verbunden ist. Ich beginne jetzt mit Vagrant Networking, also habe ich ein bisschen Probleme mit ihr. Danke im Voraus!

0

0 Antworten auf die Frage