Class: WebServerConfigGenerator::NginxConf
- Inherits:
-
Object
- Object
- WebServerConfigGenerator::NginxConf
- Defined in:
- lib/web_server_config_generator/nginx_conf.rb
Instance Method Summary collapse
- #base_uri_lines ⇒ Object
- #contents ⇒ Object
-
#initialize(options) ⇒ NginxConf
constructor
A new instance of NginxConf.
- #rewrite_line ⇒ Object
Constructor Details
#initialize(options) ⇒ NginxConf
Returns a new instance of NginxConf.
3 4 5 6 7 |
# File 'lib/web_server_config_generator/nginx_conf.rb', line 3 def initialize() @options = raise ArgumentError.new("Must supply port, server_names, root, and environment") unless [:port] && [:server_names] && [:root] && [:environment] end |
Instance Method Details
#base_uri_lines ⇒ Object
13 14 15 |
# File 'lib/web_server_config_generator/nginx_conf.rb', line 13 def base_uri_lines @options[:base_uri_names] && @options[:base_uri_names].map { |n| " passenger_base_uri /#{n};\n" }.join end |
#contents ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/web_server_config_generator/nginx_conf.rb', line 17 def contents server_names = @options[:server_names].map { |h| "#{h} *.#{h}" }.join(" ") <<-END server { listen #{@options[:port]}; listen 80; server_name #{server_names}; root #{@options[:root]}; passenger_enabled on; #{rewrite_line} rails_env #{@options[:environment]}; rails_spawn_method conservative; #{base_uri_lines} client_max_body_size 100m; client_body_timeout 300; } END end |
#rewrite_line ⇒ Object
9 10 11 |
# File 'lib/web_server_config_generator/nginx_conf.rb', line 9 def rewrite_line @options[:sub_uri_root_app] && " rewrite ^/$ /#{@options[:sub_uri_root_app]} redirect;" end |