2014-09-29 2 views
1

문제가 있습니다. Windows 7을 사용하고 Vagrant Box (Lucid32)를 실행하고 그 안에 Nginx Server를 실행 중입니다.Vagrant를 사용하는 Nginx의 포트 포워딩

내가

$ curl localhost:80 

를 실행하면 내가 Nginx에의 시작 페이지를 완벽하게 볼 수 있습니다.

그러나 Windows에서는 포트 2000 (내가 만든 모음) 에 도달 할 수 없습니다.

그렇지 않으면 레일즈 서버를 실행하면 VM 외부에서 연결할 수 있습니다.

은 내가 nginx.conf이 기본 구성을했다 :

server{ 
    listen 8080; 
    server_name localhost; 
    access_log /usr/local/nginx/logs/access.log; 
    access_log /usr/local/nginx/logs/error.log; 
    location /{ 
    root /var/www; 
    index index.html index.html; 
    } 

} 

내 vagrantfile :

Bringing machine 'default' up with 'virtualbox' provider... 
[default] Clearing any previously set forwarded ports... 
[default] Fixed port collision for 2000 => 80. Now on port 2200. 
[default] Creating shared folders metadata... 
[default] Clearing any previously set network interfaces... 
[default] Preparing network interfaces based on configuration... 
[default] Forwarding ports... 
[default] -- 22 => 2222 (adapter 1) 
[default] -- 3000 => 3000 (adapter 1) 
[default] -- 2000 => 8080 (adapter 1) 
[default] -- 2000 => 2200 (adapter 1) 
[default] Booting VM... 
[default] Waiting for machine to boot. This may take a few minutes... 
[default] Machine booted and ready! 
[default] The guest additions on this VM do not match the installed version of 
VirtualBox! In most cases this is fine, but in rare cases it can 
cause things such as shared folders to not work properly. If you see 
shared folder errors, please update the guest additions within the 
virtual machine and reload your VM. 

Guest Additions Version: 4.2.0 
VirtualBox Version: 4.3 
[default] Mounting shared folders... 
[default] -- /vagrant 

감사 : 방랑 최대 명령에 의해

VAGRANTFILE_API_VERSION = "2" 

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 
    config.vm.box = "lucid32" 

    config.vm.network :forwarded_port, guest: 3000, host: 3000 # rails 
    #config.vm.network :forwarded_port, guest: 3306, host: 3306 # mysql 
    config.vm.network :forwarded_port, guest: 2000, host: 80 # apache/nginx 
end 

출력!

답변

2

모든 것을 올바르게 읽는다면 포트 번호를 반대로 입력했을 수도 있습니다. 당신은 게스트 OS (리눅스) 내부 포트 8080에서 실행의 nginx를하고 호스트 OS (윈도우)의 포트 (80)로 표시 할 경우 예를 들어, 그 선이 보일 것 같은 :

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

그러나, Vagrantfile 당신은 게시했고 유증 자의 기록은 일치하지 않는 것 같습니다. (각각의 경우에 동일한 포트가 언급되지는 않습니다.)

+0

네가 맞아! 방금 포트 번호를 바꿨습니다. 이와 같이 : config.vm.network : forwarded_port, guest : 80, host : 2000 – Raphael