标签: unicorn

Nginx 和 Unicorn 在不同的机器上

我有一个非常标准的 Rails 应用程序,可以在一个盒子上运行 Unicorn 和 Nginx。我想分离应用程序本身,并在一台机器上安装 Nginx,在另一台机器上安装 Unicorn(带有 Rails 应用程序)。这里的想法是我想在以后的 Unicorn 中添加另一个应用程序服务器,主要是为了一些轻负载平衡。

我可能是从错误的角度来解决这个问题的。这是正常的/可能的吗?如果是这样,有人可以指出我的示例配置或文档吗?

如果这不是要走的路,那么实现最终目标的正确途径是什么?我已经研究过 HAProxy,但在阅读了一些 Nginx/Unicorn 文档后,我了解到无需任何其他软件即可实现这一点。

nginx load-balancing ruby-on-rails unicorn

3
推荐指数
1
解决办法
1678
查看次数

将 www.example.com 配置为 example.com

我使用 nginx 作为服务器后端

  • sqlbuddy.example.com - 用于数据库管理 (php-fpm)

  • example.com - 主站点(独角兽)

当我去 www.example.com 我得到 sqlbuddy.example.com

我如何在 www.example.com 上获取 example.com

朋友

  server {
    listen sqlbuddy.example.com:80;
    client_max_body_size 1G;
    server_name sqlbuddy.example.com;
    keepalive_timeout 5;
    root /home/example/sqlbuddy;
    index index.php;

    location ~ \.php$ {
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;

      fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
      include fastcgi_params;
    }
  }
Run Code Online (Sandbox Code Playgroud)

例子.com

  upstream example_server {
   server unix:/home/example/application/shared/unicorn.sock fail_timeout=0;
  }

  server {
    listen example.com:80;
    client_max_body_size 1G;
    server_name example.com;
    keepalive_timeout 5;
    root /home/example/application/current/public;

    try_files $uri/index.html $uri.html $uri @example_application;

    location @example_application {
        proxy_pass http://example_server;
        proxy_set_header X-Forwarded-For …
Run Code Online (Sandbox Code Playgroud)

nginx unicorn

2
推荐指数
1
解决办法
1100
查看次数

独角兽和 copy_on_write_friendly?

在研究 Unicorn 配置选项时,我遇到了这个片段..

GC.respond_to?(:copy_on_write_friendly=) and
  GC.copy_on_write_friendly = true
Run Code Online (Sandbox Code Playgroud)

如果我理解正确,它优化了 Unicorn 如何处理工人之间的内存分配和资源共享?

我使用 Unicorn 在带有 Ruby 1.9.3 的服务器上为我的 Sinatra 应用程序提供支持。在我的独角兽配置中包含copy_on_write_friendly设置有什么缺点吗?

debian configuration ruby sinatra unicorn

2
推荐指数
1
解决办法
2042
查看次数

通过 Haproxy 转发真实 IP => Nginx => Unicorn

如何将真实访客的 IP 地址转发给 Unicorn?目前的设置是:

Haproxy => Nginx => Unicorn
Run Code Online (Sandbox Code Playgroud)
  1. 如何将真实 IP 地址从 Haproxy 转发到 Nginx,再到 Unicorn?目前它总是只有 127.0.0.1
  2. 我读到 X 标头将被弃用。http://tools.ietf.org/html/rfc6648 - 这将如何影响我们?

Haproxy 配置:

# haproxy config
defaults
    log global
    mode    http
    option  httplog
    option  dontlognull
    option httpclose
    retries 3
    option redispatch
    maxconn 2000
    contimeout  5000
    clitimeout  50000
    srvtimeout  50000

# Rails Backend
backend deployer-production
    reqrep    ^([^\ ]*)\ /api/(.*)  \1\ /\2
    balance     roundrobin
    server      deployer-production localhost:9000 check
Run Code Online (Sandbox Code Playgroud)

Nginx 配置:

upstream unicorn-production {
  server unix:/tmp/unicorn.ordify-backend-production.sock fail_timeout=0;
}

server {
  listen …
Run Code Online (Sandbox Code Playgroud)

http nginx haproxy unicorn

2
推荐指数
1
解决办法
9717
查看次数

如何在 ubuntu 上正确保护 Unicorn/RoR 服务器?或者,强化 RoR 应用程序堆栈?

我在 Ubuntu 12.04 上运行的 Unicorn 服务器很少,我希望保护它们免受提供远程 shell 的攻击。

我主要关心的是,部署 ModSecurity 是否有意义?

另一件事是,我看到 Unicorn 通常从端口 8080 运行,并将其转发到用作反向代理的 Apache/NginX 服务器端口 80。

我在想我可以使用以下内容:

  • Apache 上的 ModSecurity
  • 使用 mod_qos 作为工作线程(线程)的 Apache,以防止来自任何主机的过多请求
  • 从指定用户运行独角兽服务器并通过 AppArmor 或 SELinux(如果它是 Redhat/Centos)将其隔离

我想知道,是否有另一个像 PHP Suhosin 这样的 RoR 强化框架/补丁。

ubuntu ruby-on-rails unicorn apache-2.2 apparmor

2
推荐指数
1
解决办法
1071
查看次数

应用得到了媒体,然后服务器得到了拥有。我又加了 8 台服务器,还是太慢了

我们的新应用程序今天受到了很多媒体的关注,每小时都有成千上万的新用户……但它变得太慢以至于无法使用。

我们使用的 Rails 3 补丁为最新版本、ubuntu、Unicorn、nginx、postgresql、memcache。

我已经添加了 8 台新服务器,但几乎没有什么不同。我还尝试将 nginx 的 keepalive 值设置为 1。除了添加更多服务器之外,我不知道如何改进响应时间。我有 10 个独角兽工人在每台服务器上运行。问题似乎是每个服务器上的请求队列太长。我可能是错的,我不完全确定是什么原因造成的,我只知道它昨天在当前负载的 2% 下运行良好。

任何帮助是极大的赞赏

ubuntu nginx ruby-on-rails unicorn

0
推荐指数
1
解决办法
79
查看次数