2013-06-21 2 views
1

레일 서버가 2 개의 다른 포트에서 수신 대기하도록하려고합니다. 한 가지 해결책은 nginx를 사용하는 것이 었습니다. 나는 sudo passenger-install-nginx-module와의 nginx를 설치하고 /etc/nginx/conf.d에 다음과 같은 추가 :nginx + passenger + rails : 레일 서버를 시작하거나 nginx를 시작해야합니까?

server { 
    listen  80; 
    listen  10000; 
    server_name www.myapp.com 
    passenger_enabled on; 
    root /root/myapp/public;} 

내가 403 금지 오류가 발생했습니다 www.myapp.com에 갔을 때를. 나는/public에 정적 HTML 파일이 없기 때문에 그것이라고 생각했습니다. 나는 간단한 "hello world"html 페이지를 거기에 놓았으며 제대로로드되었다. 그런 다음 passenger start -e production을 사용하여 레일 앱을 시작하여 포트 3000의 독립형 phusion 여객 모드에서 실행하게했습니다. myapp.com : 3000으로 이동하여 앱을 얻습니다. 그러나 myapp : 80 및 myapp : 10000은 여전히 ​​작동하지 않습니다. 내가 실행중인 레일 서버를 가리 키도록 내 nginx를 얻는 방법에 대해 혼란 스럽다. 이 일을 완전히 잘못하고 있습니까? 감사!

+0

Nginx에 여객과 함께 시작하고 레일 서버입니다 사용하여 내 레일 서버에 전달합니다. 승객은 모듈로 nginx로 컴파일되고 실제로 독립 실행 형 모드에서도 nginx를 통해 계속 실행됩니다. – cpuguy83

답변

0

설정의 nginx이 https://gist.github.com/jeffrafter/1229497

worker_processes 1; 

error_log /usr/local/var/log/nginx.error.log; 

events { 
    worker_connections 1024; 
} 

http { 
    include   mime.types; 
    default_type  application/octet-stream; 
    sendfile   on; 
    keepalive_timeout 65; 

    upstream dev { 
     server 127.0.0.1:3000; 
    } 

    server { 
     listen  80; 

     # You could put a server_name directive here (or multiple) if 
     # you have not setup wildcard DNS for *.dev domains 
     # See http://jessedearing.com/nodes/9-setting-up-wildcard-subdomains-on-os-x-10-6 

     # If we choose a root, then we can't switch things around easily 
     # Using /dev/null means that static assets are served through 
     # Rails instead, which for development is okay 
     root   /dev/null; 

     index  index.html index.htm; 

     try_files $uri/index.html $uri.html $uri @dev; 

     location @dev { 
     proxy_set_header X-Real-IP  $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Host    $http_host; 
     proxy_redirect off; 
     proxy_pass  http://dev; 
     } 
     error_page 500 502 503 504 /50x.html; 
    }    
} 
관련 문제