Class: Nginx::Builder::Base
- Inherits:
-
Object
- Object
- Nginx::Builder::Base
- Defined in:
- lib/shared_infrastructure/nginx/builder.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#domain_name ⇒ Object
readonly
Returns the value of attribute domain_name.
-
#server_blocks ⇒ Object
readonly
Returns the value of attribute server_blocks.
Instance Method Summary collapse
- #https_reminder_message ⇒ Object
-
#initialize(domain_name, *server_blocks) ⇒ Base
constructor
A new instance of Base.
- #save ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(domain_name, *server_blocks) ⇒ Base
Returns a new instance of Base.
34 35 36 37 38 39 |
# File 'lib/shared_infrastructure/nginx/builder.rb', line 34 def initialize(domain_name, *server_blocks) # puts "Base#initialize domain_name: #{domain_name}" # puts "Base#initialize server_blocks.inspect: #{server_blocks.inspect}" @server_blocks = server_blocks @domain_name = domain_name end |
Instance Attribute Details
#domain_name ⇒ Object (readonly)
Returns the value of attribute domain_name.
52 53 54 |
# File 'lib/shared_infrastructure/nginx/builder.rb', line 52 def domain_name @domain_name end |
#server_blocks ⇒ Object (readonly)
Returns the value of attribute server_blocks.
52 53 54 |
# File 'lib/shared_infrastructure/nginx/builder.rb', line 52 def server_blocks @server_blocks end |
Instance Method Details
#https_reminder_message ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shared_infrastructure/nginx/builder.rb', line 16 def 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_name)} #{Nginx.certbot_domain_names(domain_name)} You can test renewal with: sudo certbot renew --dry-run Finally, re-run this script to configure nginx for TLS. ) end |
#save ⇒ Object
41 42 43 44 45 46 |
# File 'lib/shared_infrastructure/nginx/builder.rb', line 41 def save File.open(Nginx.server_block_location(domain_name), "w") do |f| f << to_s end `ln -fs ../sites-available/#{domain_name} #{Nginx.enabled_server_block_location(domain_name)}` end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/shared_infrastructure/nginx/builder.rb', line 48 def to_s server_blocks.map(&:to_s).join("\n") end |