前提・実現したいこと
vagrant環境下でサーバーを立ち上げて、ホスト(windows10)からアクセスをしたい。
実際にFirebaseでサーバーを立ち上げ、ブラウザとcurlでlocalhost:5000にアクセスしてみたのですが、
「このサイトにアクセスできません」というメッセージが出てしまいます。
SElinux、firewall、Vagrantfileなど思い当たるところはやってみたのですが、解決に至っていません。
他に見直すべき箇所はございますでしょうか。
原因が分かる方がおられましたら、よろしくお願いいたします。
発生している問題・エラーメッセージ
vagrant環境下でサーバーを立ち上げて、ホストからアクセスができない。
エラーメッセージ
C:\Users{user name}>curl -I localhost:5000
curl: (56) Recv failure: Connection was reset
該当のソースコード
- コマンドライン(vagrant centos7)
$ firebase serve
vagrant@localhost public]$ ls
404.html index.html
[vagrant@localhost public]$ firebase serve
=== Serving from '/home/vagrant'...
i hosting: Serving hosting files from: public
✔ hosting: Local server: http://localhost:5000
[vagrant@localhost ~]$ curl -I localhost:5000
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 3505
ETag: fe4132915b7c7eacd8a396745f917c18
Last-Modified: Tue, 04 Jun 2019 14:35:15 GMT
Date: Sun, 09 Jun 2019 03:20:10 GMT
Connection: keep-alive
- ホスト側(windows10)
localhostへ繋がるか確認
C:\Users{user name}>curl -I localhost:5000
curl: (56) Recv failure: Connection was reset
httpdで繋がるipに変更して実行
C:\Users{user name}>curl -I 192.168.33.10:5000
curl: (7) Failed to connect to 192.168.33.10 port 5000: Connection refused
- Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 5000, host: 5000
config.vm.network "forwarded_port", guest: 9005, host: 9005
config.vm.network "private_network", ip: "192.168.33.10"
end
試したこと
- SELinuxの確認
$ getenforce
Disabled
- firewallの確認
$ firewall-cmd --state
not running
・競合サーバーが動いていないこと(httpdが立ち上がっていないこと)の確認
[vagrant@localhost ~]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
- httpdサーバー利用時
vagrant
[vagrant@localhost public]$ sudo systemctl start httpd
[vagrant@localhost public]$ curl -i 127.0.0.1:80
HTTP/1.1 200 OK
Date: Sun, 09 Jun 2019 03:54:44 GMT
Server: Apache/2.4.6 (CentOS)
Last-Modified: Thu, 06 Jun 2019 15:01:44 GMT
ETag: "16-58aa8fe02307a"
Accept-Ranges: bytes
Content-Length: 22
Content-Type: text/html; charset=UTF-8
<h1>hello apache</h1>
windows10
localhostで繋がるか確認
C:\Users{user name}>curl -I localhost:80
curl: (7) Failed to connect to localhost port 80: Connection refused
localhostをipに変更して確認
C:\Users{user name}>curl -I 192.168.33.10:80
HTTP/1.1 200 OK
Date: Sun, 09 Jun 2019 03:57:58 GMT
Server: Apache/2.4.6 (CentOS)
Last-Modified: Thu, 06 Jun 2019 15:01:44 GMT
ETag: "16-58aa8fe02307a"
Accept-Ranges: bytes
Content-Length: 22
Content-Type: text/html; charset=UTF-8
補足情報(FW/ツールのバージョンなど)
Vagrant 2.1.2
CentOS Linux release 7.6.1810 (Core)
windows10 Home
回答1件
あなたの回答
tips
プレビュー