[pve-devel] [PATCH manager 1/2] pass proxied to node to proxy_request

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Nov 16 14:24:14 CET 2016


in addition to proxied to IP
---
note just needed for patch #2

 PVE/HTTPServer.pm | 6 +++---
 PVE/REST.pm       | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/PVE/HTTPServer.pm b/PVE/HTTPServer.pm
index 1712c10..1c7d033 100755
--- a/PVE/HTTPServer.pm
+++ b/PVE/HTTPServer.pm
@@ -564,7 +564,7 @@ sub websocket_proxy {
 }
 
 sub proxy_request {
-    my ($self, $reqstate, $clientip, $host, $method, $uri, $ticket, $token, $params) = @_;
+    my ($self, $reqstate, $clientip, $host, $node, $method, $uri, $ticket, $token, $params) = @_;
 
     eval {
 	my $target;
@@ -738,8 +738,8 @@ sub handle_api2_request {
 
 	    $res->{proxy_params}->{tmpfilename} = $reqstate->{tmpfilename} if $upload_state;
 
-	    $self->proxy_request($reqstate, $clientip, $host, $method,
-				 $r->uri, $auth->{ticket}, $auth->{token}, $res->{proxy_params});
+	    $self->proxy_request($reqstate, $clientip, $host, $res->{proxynode}, $method,
+				 $r->uri, $auth->{ticket}, $auth->{token}, $res->{proxy_params}, $res->{proxynode});
 	    return;
 
 	} elsif ($upgrade && ($method eq 'GET') && ($path =~ m|websocket$|)) {
diff --git a/PVE/REST.pm b/PVE/REST.pm
index bf7ce15..ccbb7cc 100644
--- a/PVE/REST.pm
+++ b/PVE/REST.pm
@@ -155,9 +155,10 @@ sub rest_handler {
 
     if ($info->{proxyto}) {
 	my $remip;
+	my $node;
 	eval {
 	    my $pn = $info->{proxyto};
-	    my $node = $uri_param->{$pn};
+	    $node = $uri_param->{$pn};
 	    die "proxy parameter '$pn' does not exists" if !$node;
 
 	    if ($node ne 'localhost' && $node ne PVE::INotify::nodename()) {
@@ -169,7 +170,7 @@ sub rest_handler {
 	    return &$exc_to_res($info, $err);
 	}
 	if ($remip) {
-	    return { proxy => $remip, proxy_params => $params };
+	    return { proxy => $remip, proxynode => $node, proxy_params => $params };
 	}
     } 
 
-- 
2.1.4





More information about the pve-devel mailing list