- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 ubuntu 14.04 LTS 在谷歌计算引擎 VM 上运行带有 puma、capistrano 和 nginx 的 rails 应用程序。
我在外部 IP 上运行了 nginx。当我访问它时,我在日志中收到两个 nginx 错误:
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: "###.###.###.###"
setsebool httpd_can_network_connect on
正如这里所建议的:
setsebool: SELinux is disabled.
但问题仍然存在。
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 service nginx restart
运行 nginx
RACK_ENV=production bundle exec puma -p 3000
它返回:
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
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...
#!/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
rvmsudo rails server -p 80
它返回:
=> 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>'
rvmsudo rails server -p 80
它再次返回:
=> 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
The server refused the connection.
与原文相反:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
RACK_ENV=production bundle exec puma -p 80
并得到:
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>'
sudo RACK_ENV=production bundle exec puma -p 80
但刚刚返回:
Your Ruby version is 1.9.3, but your Gemfile specified 2.1.7
最佳答案
我和你有同样的错误,我有一个解决方案,但不知道它是否正确。
更改文件 /etc/nginx/nginx.conf
的第一行user www-data;
到user root;
然后使用以下命令重新启动 nginx:service nginx restart
或 systemctl restart nginx
警告:这会以 root
的身份运行您的 Web 服务器。用户。这绝不应该在生产环境中完成,因为它允许 Web 服务器进程完全访问您的系统。如果 Web 服务器进程受到威胁,攻击者将可以不受限制地访问您的整个服务器。
关于ruby-on-rails - nginx 错误 : (13: Permission denied) while connecting to upstream),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35177177/
根据这个article , git push --set-upstream 已弃用,应改用 git push --set-upstream-to。 但是当我检查 git push文档,我只能找到--s
无意中,创建了一个分支remotes/upstream/upstream/develop。上游受 GitHub 控制。标准删除命令失败: $ git fetch --all $ git branch
我的网站在端口 80 (http) 上运行,我使用 nginx 没有任何问题。下面是我在 nginx 中使用的默认文件 server { listen 80; server_name
这个问题在这里已经有了答案: Undo a Git merge that hasn't been pushed yet (35 个答案) 关闭 9 年前。 这个问题与其他问题的不同之处在于,我想在恢
我们在 NGINX 后面有带有 Jersey 服务 API 的 tomcat。我们开发的一个新的流式 API 在我们直接调用 Tomcat 时运行良好,但在通过 NGINX 调用它时开始没有响应。 查
在我的 Remote 列表中,我看到:(git branch -r) upstream/HEAD -> upstream/master 当然,我有一个 upstream/master,origin 是
git rebase upstream/master 和 git pull --rebase upstream master 之间有区别吗?如果有,那是什么?远程可以是任何远程,不一定是上游。 最佳答
我正在尝试按照一些步骤为 GitHub 上的存储库做贡献,但其中一个步骤不起作用。步骤在这里:https://github.com/wdbm/qTox/blob/master/CONTRIBUTING
我使用本教程部署了一个 Django 网站 https://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html 该网站可从互联网 ww
TL; 博士 Nginx 日志时出现什么http/tcp 现象upstream prematurely closed connection while reading response header
我有一个 Django 应用程序,用户可以使用该应用程序使用多个视频创建视频拼贴画。问题是,在生产中,当将视频上传到 amazon s3 时,我得到一个 502 错误的网关(在本地工作正常)。有谁知道
我的 rails nginx/unicorn 服务器出现上游超时错误。我已尝试解决此问题,但没有找到适合我的解决方案。 我正在粘贴我在 nginx error.log 文件中得到的确切错误: ups
我目前总是在我的用户正在执行的查询中得到 502...这通常返回 872 行并且需要 2.07 才能在 MySQL 中运行。然而,它返回了很多信息。 (每一行都包含很多东西)。有什么想法吗? 运行 D
我在错误日志中收到如下 nginx 错误: [error] 4257#0: *3470 upstream timed out (110: Connection timed out) while rea
我试图将更改从上游 pull 到我的分支中。我试过 git fetch https://github.com/someuser/someproject,但它顽固地拒绝做任何事情。它只是说了一些完全隐晦
/编辑我做了the answer to the question mentioned above的建议授予对注册表的访问权限,如下所示: sudo mkdir -p /usr/local/etc/mo
配置例子 ? 1
我用 upstream和 proxy用于负载平衡。 指令 proxy_pass http://upstream_name使用默认端口,即 80。 但是,如果上游服务器不监听此端口,则请求将失败。 如何
我使用 nginx 作为代理服务器将请求转发到我的 gunicorn 服务器。当我运行 sudo nginx -t -c/etc/nginx/sites-enabled/mysite 时,出现以下错误
我的 git 似乎一团糟。 我首先重命名了一个名为分支 Sprint/13/Story/XXX-11 的分支 使用这个: git branch -m Sprint13/Story/XXX-11 这并没
我是一名优秀的程序员,十分优秀!