class Nginx::Builder::Base

Attributes

domain[R]
server_blocks[R]

Public Class Methods

new(*server_blocks, domain: nil) click to toggle source
# File lib/shared_infrastructure/nginx/builder.rb, line 37
def initialize(*server_blocks, domain: nil)
  # puts "Base#initialize domain_name: #{domain_name}"
  # puts "Base#initialize server_blocks.inspect: #{server_blocks.inspect}"
  @server_blocks = server_blocks
  @domain = domain
end

Public Instance Methods

https_reminder_message() click to toggle source
# File lib/shared_infrastructure/nginx/builder.rb, line 19
      def https_reminder_message
        puts %(You have to obtain a certificate and enable TLS for the site.
To do so, reload the Nginx configuration:

sudo nginx -s reload

Then run the following command:

sudo certbot certonly --webroot -w #{Nginx.root_directory(domain.domain_name)} #{domain.certbot_domain_names}

You can test renewal with:

sudo certbot renew --dry-run

Finally, re-run this script to configure nginx for TLS.
)
      end
save() click to toggle source
# File lib/shared_infrastructure/nginx/builder.rb, line 44
def save
  puts "writing server block: #{Nginx.server_block_location(domain.domain_name)}" if Runner.debug
  File.open(Nginx.server_block_location(domain.domain_name), "w") do |f|
    f << to_s
  end
  puts "enabling site" if Runner.debug
  `ln -fs ../sites-available/#{domain.domain_name} #{Nginx.enabled_server_block_location(domain.domain_name)}`
end
to_s() click to toggle source
# File lib/shared_infrastructure/nginx/builder.rb, line 53
def to_s
  server_blocks.map(&:to_s).join("\n")
end