2014-06-26 34 views
0

因此,我部署了我的Rail 3應用程序,它具有相當標準的NGinx和Thin配置。但我堅持了三個問題 -無法在NGinx和Thin上訪問Rails應用程序而無需在URL中使用端口

  • ,我只能通過端口附加到URL(domain.com:port)
  • 是www.domain.com仍顯示nginx的歡迎屏幕上訪問應用程序和
  • 在訪問URL中使用端口應用程序應該理想地不工作

我的Nginx的conf:

upstream thin_cluster { 
    <ip_address>:3000; 
    <ip_address>:3001; 
    <ip_address>:3002; 
} 

server { 
     listen  80; 
     server_name domain.com www.domain.com; 

     root /home/deployer/apps/appname/current/public; 

     location ^~ /assets/ { 
     gzip_static on; 
     gzip_disable "msie6"; 
     expires max; 
     add_header Cache-Control public; 
     } 

     location/{ 
       try_files $uri @thin; 
     } 

     location @thin { 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Host $http_host; 
     proxy_redirect off; 
     proxy_pass http://thin_cluster; 
     } 

     error_page 500 502 503 504 /500.html; 

     client_max_body_size 50M; 
     keepalive_timeout 10; 
} 

My Thin conf:

--- 
chdir: /home/deployer/apps/appname/current 
environment: production 
address: 0.0.0.0 
port: 3000 
timeout: 30 
log: log/thin.log 
pid: tmp/pids/thin.pid 
max_conns: 1024 
max_persistent_conns: 100 
require: [] 
wait: 30 
servers: 3 
daemonize: true 
onebyone: true 

回答

0

好的,無數次回答我的問題。這是一個非常愚蠢的錯誤,也許是因爲睡眠不足。

的問題就在這裏

upstream thin_cluster { <ip_address>:3000; <ip_address>:3001; <ip_address>:3002; }

它應該包含在其薄運行的本地主機地址。因此,這將是:

upstream thin_cluster { 127.0.0.1:3000; 127.0.0.1:3001; 127.0.0.1:3002; }

但是我仍然可以通過附加的端口號來訪問它的應用程序。理想情況下,這應該重定向到正確的URL。也許proxy_redirect可以提供幫助嗎?

+1

您需要防火牆本地端口或使用套接字連接方案。 –

相關問題