如何正确配置 nginx 以在 Digital Ocean 上的 Ubuntu 16.04 上使用 rails

如何正确配置 nginx 以在 Digital Ocean 上的 Ubuntu 16.04 上使用 rails

我决定在我管理的网站上安装最新的 ubuntu 16.04 系统,结果却接二连三地出现问题。我的 mysql 服务器出现了问题,我不确定是否已经完全修复,因为有时我会遇到 mysql 连接错误。我放弃了设置 spam assasin。但我至少希望网站能像以前一样运行。我遇到了这些奇怪的 nginx 错误,我无法理解。过去,我能够成功部署各种 rails 应用程序,而不会出现重大问题。但在这里,我陷入了无可救药的困境。我的网站大部分功能正常,但有些链接却无法使用。http://chrisbeard-images.com/photos?tag=Bridges

它们在本地开发机器上似乎运行良好,在我重新安装系统之前也完全正常。

$ tail log/nginx.error.log 给出了我无法理解的错误

2016/06/20 21:01:34 [info] 17909#17909: *41 client closed connection while waiting for request, client: 86.22.165.132, server: 0.0.0.0:80

$ 尾日志/nginx.access.log

86.22.165.132 - - [20/Jun/2016:20:48:24 -0400] "GET /photos?tag=Bridges HTTP/1.1" 500 643 "http://chrisbeard-images.com/tags“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0”

$ cat /etc/nginx/nginx.conf

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events { worker_connections 1024; }

http {
        client_max_body_size 2048M;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    gzip on;
    gzip_disable "msie6";
    gzip_types text/plain text/xml text/css text/comma-separated-values;
        upstream app_server { server 127.0.0.1:8080 fail_timeout=0; }

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

$ cat /etc/nginx/sites-enabled/default

upstream puma {
  server unix:///home/chris/Rails/chrisbim2ree/shared/tmp/sockets/chrisbim2ree-puma.sock;
}

server {
  listen 80 default_server deferred;
  # server_name example.com;

  root /home/chris/Rails/chrisbim2ree/current/public;
  access_log /home/chris/Rails/chrisbim2ree/current/log/nginx.access.log;
  error_log /home/chris/Rails/chrisbim2ree/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;
}

相关内容