Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps::protocols::http::plugin --http-peer-addr #5002

Open
cmertz-sop opened this issue Apr 29, 2024 · 1 comment
Open

apps::protocols::http::plugin --http-peer-addr #5002

cmertz-sop opened this issue Apr 29, 2024 · 1 comment
Labels

Comments

@cmertz-sop
Copy link

--http-peer-addr arguement doesn't work as expected

When I use --http-peer-addr the get address should be replaced by toto.my.domain.com but it isn't the case, in debug mode it is still the ip adress who is used .

/usr/lib/centreon/plugins//centreon_protocol_http.pl --plugin=apps::protocols::http::plugin --mode=response --hostname=ip_address --proto='https' --port='' --urlpath='/WSWebClient/Default.aspx' --warning='' --critical='' --http-peer-addr='toto.my.domain.com' --debug
CRITICAL: 404 Not Found | 'time'=0.114s;;;0; 'size'=19B;;;0;
======> request send
GET https://ip_address/WSWebClient/Default.aspx
User-Agent: centreon::plugins::backend::http::useragent

======> response done
HTTP/1.1 404 Not Found
Date: Mon, 29 Apr 2024 15:28:28 GMT
Content-Length: 19
Content-Type: text/plain; charset=utf-8
Client-Date: Mon, 29 Apr 2024 15:28:28 GMT
Client-Peer: 172.21.0.110:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /DC=com/DC=soprema/DC=ad/CN=SRVEUCAA02-CA
Client-SSL-Cert-Subject: /CN=*ad..soprema.com
Client-SSL-Cipher: TLS_AES_256_GCM_SHA384
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Version: TLSv1_3
X-Content-Type-Options: nosniff

404 page not found

@lucie-dubrunfaut
Copy link
Contributor

lucie-dubrunfaut commented Jul 18, 2024

Hello :)

If I understand correctly the request should have been :

======> request send
GET https://toto.my.domain.com/WSWebClient/Default.aspx
User-Agent: centreon::plugins::backend::http::useragent

======> response done

and this would have been a functional request in your case?

From what I found the --http-peer-addr option is involved in two calls during plugin initialization:
First at line 47 when calling lwp mode, the option is checked line 188 and then in http plugin at line 54 when calling curl mode, the option is checked line 350 :

if (defined($options{request}->{http_peer_addr}) && $options{request}->{http_peer_addr} ne '') {
        $url =~ /^(?:http|https):\/\/(.*?)(\/|\:|$)/;
        $self->{curl_easy}->setopt(
            $self->{constant_cb}->(name => 'CURLOPT_RESOLVE'),
            [$1 . ':' . $options{request}->{port_force} . ':' . $options{request}->{http_peer_addr}]
        );
    }  

in your case the url won't match I think the "http" or "https" is missing in the option (maybe we should add something about it in the option help). Could you test with "http//toto.my.domain.com" or "https//toto.my.domain.com" in the option --http-peer-addr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants