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

Collect Task not working when a proxy is set. #645

Open
JulienRemi opened this issue Apr 15, 2024 · 5 comments
Open

Collect Task not working when a proxy is set. #645

JulienRemi opened this issue Apr 15, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@JulienRemi
Copy link

JulienRemi commented Apr 15, 2024

Bug reporting acknowledgment

Yes, I read it

Professional support

None

Describe the bug

The agent doesn't put cookies informations in his POST request for the collect task when a proxy is set in the GLPI-agent configuration.

Here is the request when no proxy is set up :
image

And with a proxy :
image

I received the Set-cookie header in both case in the previous request.

Then, the collect task throw an error on the POST request when a proxy is used by the agent, because it receive an html Access Refused page :

[Thu Apr  4 16:17:52 2024][debug2] [http client] POST: action=setAnswer&_sid=7&_cpt=1&uuid=660eb484740a3&tag=XXXXXX
[Thu Apr  4 16:17:52 2024][debug] [http client] Using 'http://111.111.111.111:1111' as proxy for http protocol
[Thu Apr  4 16:17:52 2024][error] [http client] Can't decode JSON content, starting with:
<!DOCTYPE html>
<html lang="fr"       >
<head>
   <title>Accès refusé - GLPI</title>

   <meta charset="utf-8" />

      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
...

There is an error in the access-error.log file on the server :
CSRF check failed for User ID: at /plugins/glpiinventory/b/collect/?action=setAnswer&uuid=660eb484740a3&method=POST

The collect task work well when no proxy is set.

To reproduce

  1. Setup the glipiinventory-agent config with a proxy.
  2. Create a collect task for that computer
  3. Run the agent

Expected behavior

Collect task working like it does without proxy

Operating system

Windows

GLPI Agent version

1.7.3

GLPI version

10.0.14

GLPIInventory plugin or other plugin version

GLPI Inventory v1.3.5

Additional context

No response

@JulienRemi JulienRemi added the bug Something isn't working label Apr 15, 2024
@g-bougard
Copy link
Member

Hi @JulienRemi

just to clarify, did you exchange the 2 screenshots ?

I see an ip staring with 194. and another starting with 14. which one is the proxy and which one the GLPI server ? Also can you confirm we don't see 14. because you forgot a 9 in the middle somewhere.

@JulienRemi
Copy link
Author

Hi,

Yes I did exchange the two screenshot sorry I will edit my post.
But no, It's not an error in the IP, the 14. is the server address through the proxy. And the 194, without.

Here is the same request with an agent on a local network :
image

@g-bougard
Copy link
Member

Can you confirm what kind of proxy you're using and how you configured it in glpi-agent ?
This should help me to reproduce.

@JulienRemi
Copy link
Author

JulienRemi commented Apr 26, 2024

It's a forward proxy but it's something global to our compagnie and I don't have the hand on it.
I use the proxy parameter of the agent : "http://[Proxy IP]:[Port]
"

@g-bougard
Copy link
Member

Hi @JulienRemi

I just had time to try your issue.

As my test instance supports http & https accesses, I can tell you:

  1. if I uses https url, I don't have the problem
  2. if I uses http url, I have the problem. But in that case, I had to set "Agent Base URL" to the http url in the "Assets" tab in Entities Administration. If I don't do that GLPI asks GLPI Agent to use the https url for following POST request and the Collect task works in that case.

So can you clarify few points ?

  1. Does your GLPI support https ? If not, can you enable this support and try using https ?
  2. Have you set "Agent Base URL" in the "Assets" tab in your entity Administration ? And if yes, is this set to a http url ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants