| 307 | | my $request = Apache2::RequestUtil->request(); |
| 308 | | my $headersIn = $request->headers_in(); |
| 309 | | my $localAddr = $request->connection()->local_ip(); |
| 310 | | my $portStr = ''; |
| 311 | | # If the connection comes from a Proxy, redirects with the Proxy IP address |
| 312 | | if ( exists $headersIn->{Via} and exists $headersIn->{'X-Forwarded-Host'}) { |
| 313 | | $localAddr = $headersIn->{'X-Forwarded-Host'}; |
| 314 | | } else { |
| 315 | | my $apachePort = EBox::Global->getInstance(1)->modInstance('apache')->port(); |
| 316 | | if ( $apachePort != 443 ) { |
| 317 | | $portStr = ":$apachePort"; |
| 318 | | } |
| 319 | | } |
| 320 | | print($self->cgi()->redirect("https://${localAddr}${portStr}/ebox/" . $self->{redirect})); |
| 321 | | EBox::debug("redirect: " . $self->{redirect}); |
| | 307 | my $request = Apache2::RequestUtil->request(); |
| | 308 | my $headers = $request->headers_in(); |
| | 309 | my $via = $headers->{'Via'}; |
| | 310 | my $host= $headers->{'Host'}; |
| | 311 | my $fwhost = $headers->{'X-Forwaded-Host'}; |
| | 312 | # If the connection comes from a Proxy, |
| | 313 | # redirects with the Proxy IP address |
| | 314 | if (defined($via) and defined($fwhost)) { |
| | 315 | $host = $fwhost; |
| | 316 | } |
| | 317 | my $protocol; |
| | 318 | if ($request->->subprocess_env('https')) { |
| | 319 | $protocol = 'https'; |
| | 320 | } else { |
| | 321 | $protocol = 'http'; |
| | 322 | } |
| | 323 | my $url = "$protocol://${host}/ebox/" . $self->{redirect}; |
| | 324 | print($self->cgi()->redirect($url)); |