class
Amber::Configuration::ServerConfig
- Amber::Configuration::ServerConfig
- Reference
- Object
Included Modules
- YAML::Serializable
Defined in:
amber/configuration/server_config.crConstant Summary
-
DEFAULT_TRUSTED_PROXIES =
["127.0.0.0/8", "::1"] -
Loopback only: a reverse proxy on the same host (Caddy, nginx) is trusted out of the box, and nothing else is.
-
LIST_OF_TRUSTED_PROXY_HEADERS =
[TRUSTED_PROXY_HEADERS_X_FORWARDED, TRUSTED_PROXY_HEADERS_FORWARDED] -
TRUSTED_PROXY_HEADERS_FORWARDED =
"forwarded" -
#trusted_proxy_headersvalue for proxies that write the RFC 7239Forwardedheader instead. -
TRUSTED_PROXY_HEADERS_X_FORWARDED =
"x-forwarded" -
#trusted_proxy_headersvalue for proxies that writeX-Forwarded-ForandX-Forwarded-Proto(Caddy, nginx, HAProxy, cloud load balancers).
Constructors
Class Method Summary
-
.check_unix_socket!(terminates_tls : Bool, process_count : Int32) : Nil
Raises
Amber::Exceptions::ConfigurationErrorwhen a server listening on#unix_socketwould also terminate TLS or run more than one process.
Instance Method Summary
-
#after_initialize
Validates the forwarding settings read from YAML, so a bad entry fails while the settings load rather than on a request.
- #host : String
- #host=(host : String)
-
#listens_on_unix_socket? : Bool
Returns
truewhen the server listens on#unix_socketrather than TCP. - #port : Int32
- #port=(port : Int32)
- #port_reuse : Bool
- #port_reuse=(port_reuse : Bool)
- #process_count : Int32
- #process_count=(process_count : Int32)
-
#reads_forwarded_header? : Bool
Returns
truewhen the trusted proxies write the RFC 7239Forwardedheader rather than theX-Forwarded-*headers. - #secret_key_base : String
- #secret_key_base=(secret_key_base : String)
- #ssl : SSLConfig
- #ssl=(ssl : SSLConfig)
-
#trusted_proxies : Array(String)
Returns a copy of the IP addresses and CIDR blocks of the reverse proxies allowed to report the client's scheme and address.
-
#trusted_proxies=(list_of_notations : Array(String)) : Array(String)
Replaces the trusted proxy list.
-
#trusted_proxy_headers : String
Returns which forwarding headers the trusted proxies write:
"x-forwarded"(X-Forwarded-ForandX-Forwarded-Proto, the default) or"forwarded"(RFC 7239Forwarded). -
#trusted_proxy_headers=(header_family : String) : String
Sets which forwarding headers the trusted proxies write.
-
#trusted_proxy_networks : Slice(Amber::Support::TrustedProxyNetwork)
Returns the trusted proxies parsed into networks, as a read-only slice of the current snapshot: writing to it raises.
- #unix_socket : String | Nil
- #unix_socket=(unix_socket : String | Nil)
- #validate!(environment : Amber::Environment::Env | Nil = nil) : Nil
Constructor Detail
Class Method Detail
Raises Amber::Exceptions::ConfigurationError when a server listening
on #unix_socket would also terminate TLS or run more than one process.
Amber::Server#run calls it with the effective settings before it
forks or binds.
Instance Method Detail
Validates the forwarding settings read from YAML, so a bad entry fails while the settings load rather than on a request.
Returns true when the server listens on #unix_socket rather than TCP.
Returns true when the trusted proxies write the RFC 7239 Forwarded
header rather than the X-Forwarded-* headers.
Returns a copy of the IP addresses and CIDR blocks of the reverse proxies allowed to report the client's scheme and address. Assign a new list to change it; editing the returned array changes nothing.
server:
trusted_proxies:
- "127.0.0.1"
- "10.0.0.0/8"
Replaces the trusted proxy list. Raises
Amber::Exceptions::ConfigurationError when an entry is not an IP
address or CIDR block, or is a /0 block that trusts every address.
Returns which forwarding headers the trusted proxies write:
"x-forwarded" (X-Forwarded-For and X-Forwarded-Proto, the default)
or "forwarded" (RFC 7239 Forwarded). Amber reads only that family,
because a proxy passes the other family through from the client
unchanged, so believing it would let the client choose its own address
and scheme.
Sets which forwarding headers the trusted proxies write. Raises
Amber::Exceptions::ConfigurationError for a value other than
"x-forwarded" or "forwarded".
Returns the trusted proxies parsed into networks, as a read-only slice of the current snapshot: writing to it raises.
Path of a UNIX socket to listen on instead of #host and #port, for a
reverse proxy on the same machine (reverse_proxy unix//run/app.sock
in Caddy). While it is set, every UNIX socket peer counts as a trusted
proxy: such a connection is local by construction, and the socket
file's permissions decide who may open it.
Path of a UNIX socket to listen on instead of #host and #port, for a
reverse proxy on the same machine (reverse_proxy unix//run/app.sock
in Caddy). While it is set, every UNIX socket peer counts as a trusted
proxy: such a connection is local by construction, and the socket
file's permissions decide who may open it.