Skip to content

Deploying Rethoth

John Pagonis edited this page Jul 4, 2017 · 1 revision

When you run thoth -d start to start Rethoth, what happens is that an instance of Rethoth (which uses Ramaze) is executed inside a Rack compliant web application container (Ramaze adapter as it is called) in order to handle the incoming HTTP connections. By default, this Ramaze adapter is Webrick and it listens for connections on port 7000. You can change these default settings by editing thoth.conf. You could use other Web application containers such as Thin, Puma or Unicorn for example.

e.g.,

# Server settings.
  server:
    # Server adapter to use. This can be any adapter Ramaze supports.
    adapter: webrick

    # IP address on which Rethoth should listen for connections. Specify 0.0.0.0
    # if you want Rethoth to listen on all addresses.
    address: 0.0.0.0

    # Port on which the Rethoth server should listen for connections.
    port: 7000

You could, also for example, configure Rethoth to listen on port 80 and use it as your sole public web server. That’s probably not ideal if you want detailed access logs, to serve other static files, or if you need to host multiple websites on the same server. For this reason, it is usually best to use another Web server such as Apache, Nginx, or Lighttpd to proxy requests to Rethoth.

Below are some example config files illustrating how to configure different servers to run Rethoth. Primary development and testing of Rethoth is done using Nginx, so your mileage with the other servers may vary. If you run into problems or would like to suggest an improvement, please do.

Shared hosting environments using CGI or FastCGI are not currently supported.

Apache

Enable mod_proxy and mod_proxy_http. Then use a virtual host config like the following:

<VirtualHost *>
  ServerName example.com

  # Tell Apache where to log requests and errors (optional).
  CustomLog /var/log/example.com-access.log combined
  ErrorLog  /var/log/example.com-error.log

  # Pass all requests to Rethoth on port 7000.
  ProxyPreserveHost On
  ProxyPass         / http://127.0.0.1:7000/
  ProxyPassReverse  / http://127.0.0.1:7000/
</VirtualHost>

Nginx

Following is the simplest setup you can have on Nginx. Use it as a baseline if you want to do more advanced setups (e.g., with multiple application containers).

server {
  server_name example.com;

  access_log /var/log/example.com-access.log main;
  error_log  /var/log/example.com-error.log;

  location / {
    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_pass http://127.0.0.1:7000/
  }
}

Lighttpd

Enable mod_proxy by adding it to lighttpd’s server.modules list, then add a rule like this one to pass requests to Rethoth:

$HTTP["host"] =~ "example\.com" {
  proxy.server = ("" => (("host" => "127.0.0.1", "port" => 7000)))
}
Clone this wiki locally