Class: Nginx::ReverseProxyLocation

Inherits:
Location
  • Object
show all
Defined in:
lib/shared_infrastructure/nginx/location.rb

Instance Method Summary collapse

Constructor Details

#initialize(proxy_url, location = "/") ⇒ ReverseProxyLocation

Returns a new instance of ReverseProxyLocation.



100
101
102
103
# File 'lib/shared_infrastructure/nginx/location.rb', line 100

def initialize(proxy_url, location = "/")
  super location
  @proxy_url = proxy_url
end

Instance Method Details

#to_s(level = 0) ⇒ Object

Don’t change any of the response headers nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_redirect The URI is added if none is specified in the proxy_url.



109
110
111
112
113
114
115
116
117
118
# File 'lib/shared_infrastructure/nginx/location.rb', line 109

def to_s(level = 0)
  Lines.new("location #{location} {",
    "  proxy_pass #{proxy_url};",
    "  proxy_set_header Host $http_host;",
    "  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;",
    "  proxy_set_header X-Forwarded-Proto $scheme;",
    "  proxy_set_header X-Real-IP $remote_addr;",
    "  proxy_redirect off;",
    "}").format(level)
end