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:
-
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"]
- Example request:
-
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.
- Example request:
Solution
Step 1: Verify the X-Forwarded-For
Header Handling
- Execute the
curl
commands above and check the response. - Ensure that Squid correctly appends its IP address to the
X-Forwarded-For
header. - If the proxy overwrites or does not append the expected IPs, adjust its configuration (Step 2).
Step 2: Adjust Squid Configuration
- Open the Squid configuration file (e.g.,
/etc/squid/squid.conf
). - Ensure the following directive is present and correctly set:
forwarded_for on
- If missing or set to off, set it to ‘on’ via UCR:
ucr set squid/forwardedfor='on'
- 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.