J
J
jFox2014-07-20 18:19:46
Ruby on Rails
jFox, 2014-07-20 18:19:46

How to create subdomains in Rails?

Dear.
Does anyone have more or less sensible (and most importantly fresh) information on creating subdomains in a rail application.
There is a domain on Reghouse and a project on DigitalOcean.
Only Unicorn is used without Nginx, because we couldn't find any working guide on how to install them together for Rails 4+ (even the official guide on DigitalOcean doesn't work).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FanKiLL, 2014-07-20
@FanKiLL

Register subdomains in routes.rb. Or is that not working for you?

namespace :admin do
  constraints subdomain: 'admin' do
    resources :photos
  end
end

V
Viktor Vsk, 2014-07-21
@viktorvsk

What difference does nginx have, 2 or 4 rails?
habrahabr.ru/post/120368

D
Dmitry, 2014-07-27
@deemytch

Last week, it was on the ocean that I installed this bundle
.
And this piece is included in the main nginx file:

upstream rel6sa_cluster {
  server unix:/tmp/rel6sa.0.socket;
  server unix:/tmp/rel6sa.1.socket;
  server unix:/tmp/rel6sa.2.socket;
  server unix:/tmp/rel6sa.3.socket;
  server unix:/tmp/rel6sa.4.socket;
}

server {
  listen <IP>:80;
  server_name <ИМЯ СЕРВЕРА>;
  rewrite ^ https://$server_name$request_uri? permanent;
}

server {
  listen <IP>:443 ssl;
  server_name <ИМЯ СЕРВЕРА>;
  root /<ПАПКА PUBLIC проекта>;
  
  ssl_certificate "/etc/ssl/SSL.crt";
  ssl_certificate_key "/etc/ssl/SSL.key";
  ssl_session_timeout  5m;
  ssl_protocols  SSLv3 TLSv1.2;
  ssl_ciphers  HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers   on;

  if (-f $request_filename) { break; }
  location / {
    try_files /system/maintenance.html $uri/index.html $uri.html $uri @cluster;
  }

  location @cluster {
    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_redirect  off;
    proxy_pass http://rel6sa_cluster;
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question