2016/02/03 11:58:07 [info] 19754#0: *73 client closed connection while waiting for request, client: ###.##.##.###, server: 0.0.0.0:443
2016/02/03 11:58:07 [crit] 19754#0: *74 connect() to unix:///home/my-user-name/apps/my-web-app/shared/tmp/sockets/my-web-app-puma.sock failed (13: Permission denied) while connecting to upstream, client: ###.##.##.###, server: ,
request: "GET / HTTP/1.1", upstream: "http://unix:///home/my-user-name/apps/my-web-app/shared/tmp/sockets/my-web-app-puma.sock:/", host: "###.###.###.###"
注意:最后一个###.##.###.####是运行代码的google compute VM的外部IP。我相信前两个IP是我的家IP。
在连接到上游:[nginx]时,我尝试了:setsebool httpd_can_network_connect
上的httpd_can_network_connect:(13:权限被拒绝),并返回:
setsebool:SELinux被禁用。
但是问题仍然存在。
在连接到上游:[nginx]时,我也查看了(13:权限被拒绝),但它似乎是
UWSGI
所特有的
upstream puma {
server unix:///home/my-user-name/apps/my-web-app/shared/tmp/sockets/my-web-app-puma.sock;
}
server {
listen 80 default_server deferred;
listen 443 ssl;
# server_name example.com;
ssl_certificate /etc/ssl/my-web-app/my-web-app.com.chained.crt;
ssl_certificate_key /etc/ssl/my-web-app/my-web-app.key;
root /home/my-web-app/apps/my-web-app/current/public;
access_log /home/my-user-name/apps/my-web-app/current/log/nginx.access.log;
error_log /home/my-user-name/apps/my-web-app/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
我用
sudo服务nginx restart
运行nginx,然后用:rack_env=production bundle exec puma-p 3000
运行puma,它返回:
Puma starting in single mode...
* Version 2.14.0 (ruby 2.1.7-p400), codename: Fuchsia Friday
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
编辑1
有人建议我在unix上运行puma,而不是在TCP3000上运行,这样它就可以与nginx相匹配
我尝试通过以下命令在unix上运行puma:
RACK_ENV=production bundle exec puma -d -b unix:///tmp/my-web-app.sock --pidfile /tmp/puma.pid
它给出了:
Puma starting in single mode...
* Version 2.14.0 (ruby 2.1.7-p400), codename: Fuchsia Friday
* Min threads: 0, max threads: 16
* Environment: production
* Daemonizing...
它读取上面的文本,但它不会逗留,命令提示符立即再次出现,尽管'...'在最后。
这个命令似乎不起作用,所以如果有人可以建议如何在unix上运行puma,而不是在TCP3000上运行,那么我可以完成这个建议。(尽管我怀疑在与彪马有关的任何事情之前,可能会出现配置nginx的问题)
编辑2附加puma.rb
#!/usr/bin/env puma
directory '/home/my-user-name/apps/my-web-app/current'
rackup "/home/my-user-name/apps/my-web-app/current/config.ru"
environment 'production'
pidfile "/home/my-user-name/apps/my-web-app/shared/tmp/pids/puma.pid"
state_path "/home/my-user-name/apps/my-web-app/shared/tmp/pids/puma.state"
stdout_redirect '/home/my-user-name/apps/my-web-app/current/log/puma.error.log', '/home/my-user-name/apps/my-web-app/current/log/puma.access.log', true
threads 2,8
bind 'unix:///home/my-user-name/apps/my-web-app/shared/tmp/sockets/my-web-app-puma.sock'
workers 1
preload_app!
on_restart do
puts 'Refreshing Gemfile'
ENV["BUNDLE_GEMFILE"] = "/home/my-user-name/apps/my-web-app/current/Gemfile"
end
on_worker_boot do
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.establish_connection
end
end
=> Booting Puma
=> Rails 4.2.4 application starting in development on http://localhost:80
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.14.0 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:80
Exiting
/home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:233:in `initialize': Address already in use - bind(2) for "localhost" port 80 (Errno::EADDRINUSE)
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:233:in `new'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:233:in `add_tcp_listener'
from (eval):2:in `add_tcp_listener'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/rack/handler/puma.rb:33:in `run'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
=> Booting Puma
=> Rails 4.2.4 application starting in development on http://localhost:80
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Puma 2.14.0 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:80
这意味着这种方法是不正确的,因为如果没有nginx,当我访问外部IP时,它现在不会返回任何东西
服务器拒绝连接。
与原来的相反:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
如果有人知道如何防止最初的错误,任何建议都将非常感谢。
编辑5原来的问题仍然存在,但是有人能告诉我这是https问题还是ssl问题吗?
Puma starting in single mode...
* Version 2.14.0 (ruby 2.1.7-p400), codename: Fuchsia Friday
* Min threads: 0, max threads: 16
* Environment: production
* Listening on tcp://0.0.0.0:80
/home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:233:in `initialize': Permission denied - bind(2) for "0.0.0.0" port 80 (Errno::EACCES)
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:233:in `new'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:233:in `add_tcp_listener'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:98:in `block in parse'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:84:in `each'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/binder.rb:84:in `parse'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/runner.rb:119:in `load_and_bind'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/single.rb:79:in `run'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/lib/puma/cli.rb:215:in `run'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/gems/puma-2.14.0/bin/puma:10:in `<top (required)>'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/bin/puma:23:in `load'
from /home/my-user-name/apps/my-web-app/shared/bundle/ruby/2.1.0/bin/puma:23:in `<main>'
我相信这是因为端口80比其他端口具有更高的权限造成的。因此,我运行了
sudo rack_env=production bundle exec puma-p80
,但它刚刚返回:您的Ruby版本是1.9.3,但您的Gemfile指定了2.1.7
问题内容: 我正在使用Nginx和Gunicorn配置Django项目。 在Nginx服务器中访问端口时,我的错误日志文件中出现以下错误; 2014/05/30 11:59:42 [crit] 4075#0:* 6 connect()到127.0.0.1:8001在连接到上游时失败(13:权限被拒绝),客户端:127.0.0.1,服务器:localhost,请求:“ GET / HTTP / 1.
似乎有很多关于StackOverflow的问题,但不幸的是,没有什么对我有效。 我在nginx上得到了一个502坏网关,日志中有以下内容: 我正在运行上的和,我一直在数字海洋上遵循这个指南。显然,我正确地配置了,因为工作,但我一直收到权限拒绝错误,我不知道原因: 在遇到这个问题和另一个问题后,我更改了文件,并添加了、、和参数(还尝试了只设置前两个或,以及两个不同的权限设置——即使是最允许的权限设置
问题内容: 我将nginx更新为 1.4.7 ,将php 更新为 5.5.12 ,之后得到了 502错误 。在更新之前,一切正常。 nginx-error.log nginx.conf 问题答案: php更新后出现类似错误。PHP固定一个安全漏洞,其中有权限的套接字文件。 打开或,具体取决于您的版本。 取消注释所有权限行,例如: listen.group = www-data listen.mod
我在django admin(127.0.0.1:8000/admin)中尝试为用户添加个人资料照片时收到此错误消息 有人能帮我找出原因吗? OSError at /admin/role/role/6/[Errno 13]权限被拒绝:'/User'请求方法: POST请求URL:http://127.0.0.1:8000/admin/role/role/6/Django版本: 1.8.2异常类型:
我更新nginx到1.4.7和PHP到5.5.12,之后我得到了502错误。在我更新之前,一切正常。 nginx-error.log nginx。形态
我在nginx(http://52.xx.xx.xx/)上访问我的IP时遇到了502个网关错误,日志简单地说: 2015/09/18 13:03:37[错误]32636#0:*1连接()失败(111:拒绝连接),连接到上游,客户端:xx.xx.xx.xx,服务器:xx.xx.xx.xx,请求:“Get/HTTP/1.1”,上游:“UWSGI://127.0.0.1:8000”,主机:“xx.xx.