Rails:带托管两个站点的服务器的操作电缆

时间:2019-05-30 09:46:20

标签: ruby-on-rails nginx puma actioncable

我正在我的ngnix服务器上托管两个网站,除了一个站点上的操作电缆之外,两个网站都工作正常。我可以在标头远程地址中看到错误的IP,它实际上指向服务器的外部IP地址,我需要在这里做的是我的ngnix配置

upstream sitetwo {
  server unix:/var/app/sitetwo/tmp/sockets/puma.sock fail_timeout=0;
}

server {
    listen 80;
    server_name localhost IPONE demo.siteoneapp.com;

    root /var/app/siteone/siteone/public;

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

    location ~ ^/(packs|assets|images|javascripts|stylesheets|swfs|system)/ {
      gzip_static on;
      expires max;
      add_header Cache-Control public;
      access_log off;
      add_header Cache-Control public;
      add_header Last-Modified "";
      add_header ETag "";
      break;
    }


    location @siteone {
        proxy_pass http://siteone;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        access_log /var/app/siteone/siteone/log/nginx.access.log;
        error_log /var/app/siteone/siteone/log/nginx.error.log;
    }
    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}

server {
    listen 80;
    server_name IPTWO demo.sitetwoapp.com;

    root /var/app/sitetwo/public;

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

    location ~ ^/(packs|assets|images|javascripts|stylesheets|swfs|system)/ {
      gzip_static on;
      expires max;
      add_header Cache-Control public;
      access_log off;
      add_header Cache-Control public;
      add_header Last-Modified "";
      add_header ETag "";
      break;
    }

    location @sitetwo {
        proxy_pass http://sitetwo;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        access_log /var/app/sitetwo/log/nginx.access.log;
        error_log /var/app/sitetwo/log/nginx.error.log;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}

实际上,当我尝试订阅频道时出现504错误,并且在请求标头中可以看到IPTWO,应该是IPONE。

0 个答案:

没有答案