1
在使用nginx並解決所有錯誤時,出現錯誤。但是應用程序在生產服務器上以開發模式運行。麒麟,nginx連接在rails中被拒絕4
Nginx的配置
pid /tmp/nginx.pid;
error_log /home/vagrant/app/sample_app/shared/log/nginx.error.log;
events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # "on" if nginx worker_processes > 1
}
http {
include mime.types;
default_type application/octet-stream;
access_log /home/vagrant/app/sample_app/shared/log/nginx.access.log combined;
sendfile on;
tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
tcp_nodelay off; # on may be better for some Comet/long-poll stuff
# types_hash_max_size 2048;
upstream app_server {
server 192.168.33.10;
}
server {
client_max_body_size 4G;
server_name localhost;
keepalive_timeout 600s;
root /home/vagrant/app/sample_app/current;
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
# Rails error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/vagrant/app/sample_app/current;
}
}
}
獨角獸配置
listen "/tmp/unicorn.sample_app.sock"
worker_processes 4
preload_app true
user 'vagrant'
root = "/home/vagrant/app/sample_app/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"
# listen "/tmp/unicorn.sample_app.sock"
worker_processes 2
timeout 30
# Force the bundler gemfile environment variable to
# reference the capistrano "current" symlink
before_exec do |_|
ENV["BUNDLE_GEMFILE"] = File.join(root, 'Gemfile')
end
收到錯誤: -
connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.33.1, server: 192.168.33.10, request: "GET/HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "192.168.33.10"
端口號爲8080有必要嗎? –
爲什麼'server 127.0.0.1:8080'而不是'server unix:/ tmp/unicorn.sample_app.sock'? – tvieira