class Nginx::RailsLocation

Attributes

domain_name[R]

Public Class Methods

new(domain_name) click to toggle source
# File lib/shared_infrastructure/nginx/location.rb, line 74
def initialize(domain_name)
  @domain_name = domain_name
end

Public Instance Methods

to_s(level = 0) click to toggle source
# File lib/shared_infrastructure/nginx/location.rb, line 78
def to_s(level = 0)
  Lines.new("location @#{domain_name} {",
    "  # A Rails app should force \"SSL\" so that it generates redirects to HTTPS,",
    "  # among other things.",
    "  # However, you want Nginx to handle the workload of TLS.",
    "  # The trick to proxying to a Rails app, therefore, is to proxy pass to HTTP,",
    "  # but set the header to HTTPS",
    "  # Next two lines.",
    "  proxy_pass http://#{domain_name};",
    "  proxy_set_header X-Forwarded-Proto $scheme; # $scheme says http or https",
    "  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;",
    "  proxy_set_header Host $http_host;",
    "  proxy_redirect off;",
    "}").format(level)
end