[英]Nginx can't connect to localhost
i found myself following this tutorial "How To Deploy a Rails App with Puma and Nginx on Ubuntu 14.04" ( https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04 ) in order to use ngnix as load balancer. 我发现自己遵循了本教程“如何在Ubuntu 14.04上使用Puma和Nginx部署Rails应用程序”( https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with- puma-and-nginx-on-ubuntu-14-04 ),以便将ngnix用作负载平衡器。 i followed all the steps and works fine, i suppose, but at the end, when i configured the nginx config file, i can't access into the localhost (0.0.0.0:3000) it shows "Unable to connect". 我想我遵循了所有步骤并且工作正常,但是最后,当我配置了Nginx配置文件时,我无法访问localhost(0.0.0.0:3000),它显示“无法连接”。 i checked if the process is running and yes... 我检查进程是否正在运行,是的...
Here i let some files 我在这里让一些文件
/etc/nginx/sites-available/iaw2015.conf /etc/nginx/sites-available/iaw2015.conf
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:///var/www/iaw2015/shared/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
root /var/www/iaw2015/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
i ran this command sudo ln -sf /etc/nginx/sites-available/iaw2015.conf /etc/nginx/sites-enabled/iaw2015.conf
to create the link. 我运行了sudo ln -sf /etc/nginx/sites-available/iaw2015.conf /etc/nginx/sites-enabled/iaw2015.conf
来创建链接。
config/puma.rb (in my project) config / puma.rb(在我的项目中)
# Change to match your CPU core count
workers 2
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
# Set up socket location
bind "unix://#{shared_dir}/sockets/puma.sock"
# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
# Set master PID and state locations
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"
activate_control_app
on_worker_boot do
require "active_record"
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
end
Based on what you posted, nothing is running on port 3000 that you are trying to connect to. 根据您发布的内容,您尝试连接的端口3000上没有任何运行。 Instead, an app server is running on a socket located at: 相反,应用服务器正在位于以下位置的套接字上运行:
/var/www/iaw2015/shared/sockets/puma.sock
First, check that the app is running that you can communicate with it through the socket . 首先,检查应用程序是否正在运行,以确保您可以通过套接字与之通信 。
Next, try connecting to http://127.0.0.1/ This will connect to port 80, where Nginx is running. 接下来,尝试连接到http://127.0.0.1/,这将连接到运行Nginx的端口80。 It should hopefully proxy to your app and return a result. 希望它可以代理您的应用并返回结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.