Public Repository

Last pushed: a year ago
Short Description
Rails/Passenger/MySQL, modeled after https://github.com/phusion/passenger-docker
Full Description

Technologies

Ruby 2.3.0
Rails 4.2.5
Nginx
Passenger
MySQL

Multiple ruby, rails, and database support soon to come.

Nginx

Nginx Conf

Our Nginx setup comes with a default nginx.conf:

# Custom nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
daemon off; # Required for docker

include /etc/nginx/main.d/*.conf;

events {
  worker_connections 1024;
  multi_accept on;
  use epoll;
}

http {

  ##
  # Basic Settings
  ##

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 60;
  types_hash_max_size 2048;
  # server_tokens off;

  # client_body_buffer_size 10K;
  # client_header_buffer_size 1k;
  client_max_body_size 20m;
  #large_client_header_buffers 2 1k;

  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  ##
  # SSL Settings
  ##

  #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  #ssl_prefer_server_ciphers on;

  ##
  # Logging Settings
  ##

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  ##
  # Gzip Settings
  ##

  gzip on;
  gzip_disable "msie6";

  # gzip_vary on;
  # gzip_proxied any;
  gzip_comp_level 4;
  # gzip_buffers 16 8k;
  # gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  ##
  # Phusion Passenger config
  ##
  # Uncomment it if you installed passenger or passenger-enterprise
  ##

  passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;

  # passenger_ruby /home/deploy/.rbenv/shims/ruby; # If you use rbenv
  # passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.3.0/ruby; # If use use rvm, be sure to change the version number
  passenger_ruby /usr/local/bin/ruby; # If you use ruby from source

  passenger_default_user root;
  passenger_default_group root;

  ##
  # Virtual Host Configs
  ##

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
}

ENV Vars

We also have a /etc/nginx/main.d/default.conf file to leak default environmental variables through to Nginx:

# By default, Nginx removes all environment variables inherited from its
# parent process, except for the TZ variable. This is documented at
# http://nginx.org/en/docs/ngx_core_module.html#env
# Because users usually want to inherit PATH, we allow it here
# explicitly.
env PATH;

 
And a /etc/nginx/main.d/rails_env.conf file to leak default Rails environmental variables through to Nginx:

env PASSENGER_APP_ENV;
env SECRET_KEY_BASE;

 
In addition, there is a /etc/nginx/conf.d/00_app_env.conf file that sets the default Rails ENV to 'staging' for Nginx:

# /etc/nginx/conf.d/00_app_env.conf
# This file sets the default passenger app env.
# The default will be overridden when an ENV var `PASSENGER_APP_ENV` is set.

passenger_app_env staging;

 
Any *.conf file added to /etc/nginx/main.d/ will be read, so you can add any additional ENV vars you want to leak through to Passenger in there too. That way, you can set the ENV vars via AWSEB's configs or Docker command line, and they will leak through.

Nginx Virtual Hosts

We also have a /etc/nginx/sites-enabled/default default file:

server {
        listen 80 default_server;
        listen [::]:80 ipv6only=on default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;

        # ssl_certificate /.ssl/<server_certification.crt>;
        # ssl_certificate_key /.ssl/<server.key>;
        # ssl_session_timeout 5m;
        # ssl_protocols SSLv3 TLSv1;
        # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
        # ssl_prefer_server_ciphers on;

        passenger_enabled on;

        server_name _;
        root /var/app/public;
}
Docker Pull Command
Owner
posse

Comments (0)