Problem: Computerroom Module Doesn't Open Correct Room Automatically

Problem

When using the Computerroom module, the expected behavior is that the correct room is opened automatically based on the user’s session or network location. However, in some cases, the module does not open the correct room, requiring manual selection.

Investigation

This issue is likely caused by improper handling of the X-Forwarded-For header when requests are processed through a proxy, such as Squid. The expected behavior is:

  1. When making a direct request to the Apache server with a predefined X-Forwarded-For header, the server correctly processes the IP addresses.

    • Example request:
      curl 'http://10.207.36.244/univention/get/ipaddress' -X POST -H 'X-Forwarded-For: 1.2.3.4' --data-raw '{"options":{}}'
      
    • Expected output:
      ["1.2.3.4", "10.205.1.22"]
      
  2. When routing the request through the Squid proxy, the proxy should append its own IP to the X-Forwarded-For header before forwarding the request to the Apache server.

    • Example request:
      curl --proxy Administrator:univention@school1.school.test:3128 'http://10.207.36.244/univention/get/ipaddress' -X POST -H 'X-Forwarded-For: 1.2.3.4' --data-raw '{"options":{}}'
      
    • Expected output:
      ["1.2.3.4", "10.207.36.244", "10.205.1.22"]
      
    • If this does not happen correctly, the Computerroom module may not correctly determine the client’s location.

Solution

Step 1: Verify the X-Forwarded-For Header Handling

  1. Execute the curl commands above and check the response.
  2. Ensure that Squid correctly appends its IP address to the X-Forwarded-For header.
  3. If the proxy overwrites or does not append the expected IPs, adjust its configuration (Step 2).

Step 2: Adjust Squid Configuration

  1. Open the Squid configuration file (e.g., /etc/squid/squid.conf).
  2. Ensure the following directive is present and correctly set:
    forwarded_for on
    
  3. If missing or set to off, set it to ‘on’ via UCR:
    ucr set squid/forwardedfor='on'
    
  4. Restart Squid:
    systemctl restart squid
    

Conclusion

By ensuring that Squid correctly appends IP addresses to the X-Forwarded-For header and Apache properly processes them, the Computerroom module should be able to open the correct room automatically based on the client’s location.

This topic was automatically closed after 24 hours. New replies are no longer allowed.