foreman-export-nginx 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/data/export/nginx/nginx.erb +6 -6
- data/foreman-export-nginx.gemspec +1 -1
- data/lib/foreman/export/nginx.rb +13 -0
- metadata +1 -1
data/data/export/nginx/nginx.erb
CHANGED
@@ -9,17 +9,17 @@ server {
|
|
9
9
|
error_log <%= log %>/<%= app %>-nginx-error.log;
|
10
10
|
|
11
11
|
listen 80;
|
12
|
-
server_name <%= app %>.<%=
|
12
|
+
server_name <%= app %>.<%= base_domain %> <%= additional_domains %>;
|
13
13
|
|
14
|
-
<% if
|
14
|
+
<% if use_ssl %>
|
15
15
|
listen 443 ssl;
|
16
16
|
|
17
|
-
<% if
|
18
|
-
ssl_certificate <%=
|
19
|
-
ssl_certificate_key <%=
|
17
|
+
<% if ssl_cert_path && ssl_key_path %>
|
18
|
+
ssl_certificate <%= ssl_cert_path %>;
|
19
|
+
ssl_certificate_key <%= ssl_key_path %>;
|
20
20
|
<% end %>
|
21
21
|
|
22
|
-
<% if
|
22
|
+
<% if force_ssl %>
|
23
23
|
if ($ssl_protocol = "") {
|
24
24
|
rewrite ^ https://$server_name$request_uri? permanent;
|
25
25
|
}
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "foreman-export-nginx"
|
7
|
-
gem.version = '0.0.
|
7
|
+
gem.version = '0.0.17'
|
8
8
|
gem.authors = ["Pete Keen"]
|
9
9
|
gem.email = ["pete@bugsplat.info"]
|
10
10
|
gem.description = %q{Export Nginx configs using Foreman}
|
data/lib/foreman/export/nginx.rb
CHANGED
@@ -3,12 +3,25 @@ require 'foreman/export'
|
|
3
3
|
module Foreman
|
4
4
|
module Export
|
5
5
|
class Nginx < Foreman::Export::Base
|
6
|
+
|
7
|
+
def env_var(key)
|
8
|
+
val = ENV[key]
|
9
|
+
val == "" ? nil : val
|
10
|
+
end
|
11
|
+
|
6
12
|
def export
|
7
13
|
super
|
8
14
|
|
9
15
|
engine.each_process do |name, process|
|
10
16
|
next unless name == 'web'
|
11
17
|
|
18
|
+
base_domain = env_var('BASE_DOMAIN') or raise "Need a BASE_DOMAIN"
|
19
|
+
additional_domains = (env_var('ADDITIONAL_DOMAINS') || '').split(',').join(' ')
|
20
|
+
use_ssl = !!env_var('USE_SSL')
|
21
|
+
ssl_cert_path = env_var('SSL_CERT_PATH')
|
22
|
+
ssl_key_path = env_var('SSL_KEY_PATH')
|
23
|
+
force_ssl = !!env_var('FORCE_SSL')
|
24
|
+
|
12
25
|
ports = []
|
13
26
|
1.upto(engine.formation[name]) do |num|
|
14
27
|
ports << engine.port_for(process, num)
|