如何在同一个linode服务器中托管多个网站

时间:2019-03-14 09:28:24

标签: ruby-on-rails hosting nginx-config linode

我有一台linode服务器,其中托管了一个网站。

现在,我想在同一linode服务器中再配置一个网站。有可能吗?

我应该更改什么配置?

试图托管红宝石网站。一个工作正常。其路径为/root/apps/my_project_name/current/public

这是我所有项目文件都存在的地方。 当我尝试配置第二个网站时,现在我的网站位于/root/apps/my_2nd project中(所有文件夹和文件都在这里)。

我应该在Nginx文件中进行哪些更改? 请帮助

这是我的文件

  upstream puma_my_project_name_production {   server unix:/root/apps/my_project_name/shared/tmp/sockets/puma.sock fail_timeout=0; }

server {   listen 80;   server_name _;   root /root/apps/my_project_name/current/public;   try_files $uri/index.html $uri @puma_maxguard_production;

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

  location @puma_my_project_name_production {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Forwarded-Proto http;
    proxy_pass http://puma_my_project_name_production;
    # limit_req zone=one;
    access_log /root/apps/my_project_name/shared/log/nginx.access.log;
    error_log /root/apps/my_project_name/shared/log/nginx.error.log;   }   location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;   }

  location = /50x.html {
    root html;   }

  location = /404.html {
    root html;   }

  location @503 {
    error_page 405 = /system/maintenance.html;
    if (-f $document_root/system/maintenance.html) {
      rewrite ^(.*)$ /system/maintenance.html break;
    }
    rewrite ^(.*)$ /503.html break;   }

  if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){
    return 405;   }

1 个答案:

答案 0 :(得分:1)

我将提供一些建议: 1)使用Nginx + Passenger(如果尚未选择,则为可选) 2)在nginx conf中创建单独的“服务器”记录,并放置正确的域名 3)重新启动nginx

相关问题