Commit c388a1b8 authored by James T. Lee's avatar James T. Lee
Browse files

revproxy: proxy_pass -> proxy_pass_match

parent 62547117
...@@ -6,10 +6,19 @@ define nest::lib::revproxy ( ...@@ -6,10 +6,19 @@ define nest::lib::revproxy (
Optional[Integer] $port = undef, Optional[Integer] $port = undef,
Boolean $ssl = true, Boolean $ssl = true,
Optional[String[1]] $websockets = undef, Optional[String[1]] $websockets = undef,
Array[String[1]] $websockets_exceptions = [],
Boolean $preserve_host = false, Boolean $preserve_host = false,
Hash[String[1], Any] $extra_params = {}, Hash[String[1], Any] $extra_params = {},
) { ) {
if $websockets {
include '::apache::mod::proxy_wstunnel'
$websockets_proxy_pass = [{
'path' => "^/(${websockets})$",
'url' => "ws://${destination}/\$1",
'reverse_urls' => []
}]
}
$certbot_exception = @(EOT) $certbot_exception = @(EOT)
<Location "/.well-known"> <Location "/.well-known">
AllowOverride None AllowOverride None
...@@ -18,36 +27,6 @@ define nest::lib::revproxy ( ...@@ -18,36 +27,6 @@ define nest::lib::revproxy (
</Location> </Location>
| EOT | EOT
if $websockets {
include '::apache::mod::proxy_wstunnel'
}
$wsdestination = $destination.regsubst('^http', 'ws').regsubst('/$', '')
$wsexceptiondest = $destination.regsubst('/$', '')
$proxy_params = $destination ? {
/(localhost|127\.0\.0\.1)/ => {},
default => { 'keepalive' => 'On' },
}
$websockets_exceptions_proxy_pass = $websockets_exceptions.map |$ex| {
{ 'path' => $ex, 'url' => "${wsexceptiondest}${ex}", 'params' => $proxy_params }
}
$proxy_pass = [
$websockets_exceptions_proxy_pass,
$websockets ? {
undef => [],
default => { 'path' => $websockets, 'url' => "${wsdestination}${websockets}", 'params' => $proxy_params },
},
$websockets ? {
'/' => [],
default => { 'path' => '/', 'url' => $destination, 'params' => $proxy_params },
}
].flatten
nest::lib::vhost { $name: nest::lib::vhost { $name:
servername => $servername, servername => $servername,
serveraliases => $serveraliases, serveraliases => $serveraliases,
...@@ -56,9 +35,10 @@ define nest::lib::revproxy ( ...@@ -56,9 +35,10 @@ define nest::lib::revproxy (
ssl => $ssl, ssl => $ssl,
zfs_docroot => false, zfs_docroot => false,
extra_params => { extra_params => {
'custom_fragment' => $certbot_exception,
'proxy_pass' => $proxy_pass,
'proxy_preserve_host' => $preserve_host, 'proxy_preserve_host' => $preserve_host,
'proxy_pass_match' => $websockets_proxy_pass,
'proxy_dest' => "http://${destination}",
'custom_fragment' => $certbot_exception,
} + $extra_params, } + $extra_params,
} }
} }
...@@ -188,24 +188,24 @@ class nest::node::falcon { ...@@ -188,24 +188,24 @@ class nest::node::falcon {
; ;
'nzbget.nest': 'nzbget.nest':
destination => 'http://localhost:6789/', destination => 'localhost:6789',
; ;
'ombi.nest': 'ombi.nest':
destination => 'http://localhost:3579/', destination => 'localhost:3579',
; ;
'plex.nest': 'plex.nest':
destination => 'http://localhost:32400/', destination => 'localhost:32400',
websockets => '/:/websockets/', websockets => ':/websockets/.*',
; ;
'radarr.nest': 'radarr.nest':
destination => 'http://localhost:7878/', destination => 'localhost:7878',
; ;
'sonarr.nest': 'sonarr.nest':
destination => 'http://localhost:8989/', destination => 'localhost:8989',
; ;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment