Conexão recusada no Host OSX 127.0.0.1:3000 para Vagrant / VirtualBox / nginx Rails App

0

O aplicativo Rails está sendo executado na porta 3000:

$ bundle exec rails server -b 0.0.0.0
=> Booting Unicorn
=> Rails 3.2.21 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
(eval):1: warning: encountered \r in middle of line, treated as a mere space
listening on addr=0.0.0.0:3000 fd=14
worker=0 spawning...
master process ready
worker=0 spawned pid=5811
worker=0 ready

O site está disponível na máquina virtual:

$ wget 127.0.0.1:3000
--2016-05-05 05:15:54--  http://127.0.0.1:3000/
Connecting to 127.0.0.1:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: 'index.html'

        [ <=>                                   ] 42,036        --.-K/s   in 0s      

2016-05-05 05:15:55 (222 MB/s) - 'index.html' saved [42036]

Mas da máquina host:

$ wget http://127.0.0.1:3000/
--2016-05-05 00:07:02--  http://127.0.0.1:3000/
Connecting to 127.0.0.1:3000... failed: Connection refused.

Host de varredura de portas: 127.0.0.1:

 Open TCP Port:     21          ftp
 Open TCP Port:     22          ssh
 Open TCP Port:     80          http
 Open TCP Port:     88          kerberos
 Open TCP Port:     111         sunrpc
 Open TCP Port:     445         microsoft-ds
 Open TCP Port:     548         afpovertcp
 Open TCP Port:     631         ipp
 Open TCP Port:     965
 Open TCP Port:     975
 Open TCP Port:     1015
 Open TCP Port:     1019
 Open TCP Port:     2049        nfsd
 Open TCP Port:     2200        ici
 Open TCP Port:     2222        rockwell-csp2
 Open TCP Port:     3300
 Open TCP Port:     5432        postgresql
 Open TCP Port:     8080        http-alt

Este é o conteúdo básico de /private/etc/hosts :

127.0.0.1   localhost
127.0.0.1   test.localhost

255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost

192.168.33.102  vagrant  # VAGRANT: c460068dd8a5a09607cfd3402843d82a (local) / 0668df93-b211-421f-86db-bb2ff8e57175
192.168.44.44  vdd.dev  # VAGRANT: 07e9613958e0db441d6b9af1328fa214 (default) / 4d655cd6-bf5a-442a-8093-4ac431b7d890

O nginx/error.log está apenas confirmando a conexão recusada e o registro Unicorn igualmente pouco informativo, tanto quanto eu posso dizer.

Este é o conteúdo de /etc/nginx/sites-available/my_application :

upstream unicorn {
  server unix:/home/vagrant/apps/ofn_america/shared/sock/unicorn.ofn_america.sock fail_timeout=1;
}


server {
  listen 80;
  server_name   127.0.0.1;
  rewrite ^/(.*) http://127.0.0.1/$1 permanent;
}


server {
  listen 80;
  server_name 127.0.0.1;
  root /home/vagrant/apps/ofn_america/current/public;


  try_files $uri/index.html $uri @unicorn;
  location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

  location ~ ^/(assets)/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
    #add_header Last-Modified "";
    #add_header ETag "";
  }
  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 60;
}

Alguma sugestão?

Não sei mais onde procurar.

    
por MikeiLL 05.05.2016 / 07:41

1 resposta

1

Parece que você precisa encaminhar o tráfego do host para o convidado. Eu não estou familiarizado com Vagrant especificamente, mas isso parece com o que você faria:

link

    
por 05.05.2016 / 07:47