繁体   English   中英

Nginx服务器上的Unicorn + Rails拒绝连接

[英]Unicorn + Rails Refused Connection on Nginx Server

我的应用程序返回502错误:

在error.log中:

2017/10/12 15:42:28 [错误] 12727#12727:* 415 connect()到Unix:/var/www/autonomos/production/current/tmp/sockets/unicorn.sock失败(111:连接被拒绝)在连接到上游时,客户端:172.31.81.4,服务器:api.autonomosapp.com.br,请求:“ GET / v1 / auth / validate_token HTTP / 1.1”,上游:“ http:// unix:/ var / www / autonomos / production / current / tmp / sockets / unicorn.sock:/ v1 / auth / validate_token “,主持人:” api.autonomosapp.com.br“

我启用了Nginx /网站

upstream unicorn_autonomos_production {
  server unix:/var/www/autonomos/production/current/tmp/sockets/unicorn.sock fail_timeout=0;
}

server {
  listen 80;
  #listen 443 ssl;
  server_name api.autonomosapp.com.br;
  root /var/www/autonomos/production/current/public;

  access_log /var/www/autonomos/production/shared/log/access.log;
  error_log /var/www/autonomos/production/shared/log/error.log;

  client_max_body_size 500M;
  keepalive_timeout 5;
  gzip_types application/x-javascript text/css;


  location /elb-status {
    return 200;
  }

  location ~ /.well-known {
     allow all;
     root /var/www/autonomos/production/current/public;
  }


  location ~* ^/assets/ { 
    # Per RFC2616 - 1 year maximum expiry 
    # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 
    expires 1y; 
    add_header Cache-Control public; 

    # Some browsers still send conditional-GET requests if there's a 
    # Last-Modified header or an ETag header even if they haven't 
    # reached the expiry date sent in the Expires header. 
    add_header Last-Modified ""; 
    add_header ETag ""; 
    break; 
  }

  location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    if (!-f $request_filename) {
      proxy_pass http://unicorn_autonomos_production;
      break;
    }
  } 

  error_page 500 502 503 504 /500.html;
  location = /500.html {
    root /var/www/autonomos/production/current/public;
  }
}

nginx / nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    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;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

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

我的etc / init / unicorn_autonomos_production

start on runlevel [2]
stop on runlevel [016]

console owner

setuid autonomos
pre-start exec /usr/local/rvm/bin/autonomos_production_unicorn_rails -E production -c /var/www/autonomos/production/current/config/unicorn.rb -D > /tmp/upstart_autonomos_production.log 2>&1
post-stop exec kill `cat /var/www/autonomos/production/current/tmp/pids/unicorn.pid`

respawn

unicorn.stderr.log

I, [2017-10-10T04:24:00.952787 #2245]  INFO -- : reaped #<Process::Status: pid 2248 exit 0> worker=0
I, [2017-10-10T04:24:00.952946 #2245]  INFO -- : master complete

我的unicorn_autonomos_production不在init.d中,有问题吗?

当我尝试:

service unicorn_autonomos_production start

错误是:

无法启动unicorn_autonomos_production.service:找不到单元unicorn_autonomos_production.service。

我今天重新加载了Nginx服务器,我也需要初始化独角兽吗? 我能怎么做?

我在终端上执行命令:

exec /usr/local/rvm/bin/autonomos_production_unicorn_rails -E production -c /var/www/autonomos/production/current/config/unicorn.rb -D > /tmp/upstart_autonomos_production.log 2>&1

和初始化独角兽

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM