升级到Rails4后,Nginx轮循无法正常工作

时间:2020-05-12 06:23:39

标签: nginx round-robin rails-4-2-1

我最近升级到Rails 4。我的应用程序有4个进程,到目前为止,我们一直在使用基于nginx ip_hash的负载平衡,并且一切正常。最近进行了更改,以更改为轮询,当我启动应用程序并登录时,我又被重定向到登录页面。但是对于Rails 3来说也可以。我不确定要使它正常工作会缺少什么。谁能帮忙吗?

请在日志下方找到

22:25:45.146 (11332:5793660) [FWK] [FRAMEWORK] [INFO] Processing by UserSessionsController#create as HTML
22:25:45.304 (11332:5793660) [FWK] [FRAMEWORK] [INFO]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"SQ0XXT4kiwD6e+IgqJp9xM76/8zhaumgkQqV24WrtzMh3yyrN1WbyzZ8PFl78dotjSE4sNkjCfyo8Y7jZOq6/w==", "user_session"=>{"login_name"=>"admin", "login_password"=>"[FILTERED]", "is_support_entry"=>""}, "hash_path"=>""}
**22:25:45.380 (11332:5793660) [FWK] [FRAMEWORK] [WARN] Can't verify CSRF token authenticity
2**2:25:45.477 (11332:5793660) [FWK] [FRAMEWORK] [INFO] user_logins create: admin is saved with API-9a831dcd-632b-4e67-8166-9cb825f1ae78
22:25:45.555 (11332:5793660) [FWK] [FRAMEWORK] [INFO] login_root_path: is /director/login_root
22:25:45.630 (11332:5793660) [FWK] [FRAMEWORK] [INFO] app_root_path: is /director/login_root
22:25:45.733 (11332:5793660) [FWK] [FRAMEWORK] [INFO] page: is /director/login_root
22:25:45.919 (11332:5793660) [FWK] [FRAMEWORK] [INFO] Processing by UserSessionsController#new as HTML

Nginx conf

worker_processes  1;

error_log  logs/error.log crit;
pid        logs/nginx.pid;

events {
  worker_connections  1024;
}

http {
  include       mime.types;
  default_type  application/octet-stream;
  sendfile        on;
  tcp_nodelay     off;
  keepalive_timeout 75;
  client_max_body_size 10M;


  # enable dynamic gzip compression
  gzip            on;
  gzip_min_length 1000;
  gzip_types      application/xml application/x-javascript application/x-shockwave-flash
                  text/css image/png image/gif image/x-icon;

  # return precompressed .gz files, if present.
  gzip_static     on;

  upstream mongrel {
    server 127.0.0.1:5469;
  }

  upstream rails {
    #ip_hash; 
    server 127.0.0.1:5469;
    server 127.0.0.1:5470;
  }

  server {
    listen          5468 default;
    server_name     _;
    root            "../d2/public";

    location ~ ^/assets/ {
      root "../d/public";
      expires 1y;
      add_header Cache-Control public;

      add_header ETag "";
      break;
    }

    location ~* /  {


      # Setup redirection headers
      proxy_set_header   X-Real-IP         $remote_addr;
      proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
      proxy_set_header   Host              $http_host;

      proxy_buffer_size   128k;
      proxy_buffers   4 256k;
      proxy_busy_buffers_size   256k;

      # Pass the request thru
      proxy_pass         http://rails;
    }

  }

And my session_store is configured as below

myApp::Application.config.session_store :cache_store, :key => '_myApp_session'

0 个答案:

没有答案
相关问题