Forum OpenACS Development: Forcing OpenACS to redirect to a certain URL


I've re-introduced a patch into the util_current_location proc in acs-tcl/tcl/utilities-procs.tcl as the very first code of the proc:

set current_location [parameter::get_from_package_key -package_key "intranet-core" -parameter UtilCurrentLocationRedirect -default ""]
if {"" != $current_location} { return $current_location }

So basically we can set a parameter in ]po[ to force redirects to a certain URL, including protocol (http/https) and port or not-port. The point is that depending on the situation, any of these 4 combinations may be necessary.

Did I mess an easier way to configure this?

Otherwise may I suggest this patch to include in OpenACS? The parameter would obviously go into the acs-tcl section...


Posted by Gustaf Neumann on
The current logic of util_current_location is already influenced by two other package parameters, it is not a good idea to hack in just another parameter that overrules its behavior for this proc.

The logic of util_current_location was already quite complex and redundant, so i took the opportunity to refactor it to make it clearer and to implement, what is written actually in the comment of the function. I have as well added several comments to the code.

util_current_location is controlled via "ReverseProxyMode" and "SuppressHttpPort". When the server is running behind a Proxy (like nginx), it should be sufficient to set ReverseProxyMode to true (there won't be a port returned in the result unless required due to the host header field. The protocol will be correctly determined, when the reverse proxy (e.g. nginx) sets "X-SSL-Request" as required.

If - for some unknown reason - it is still required to suppress the port in all requests, also the package parameter "SuppressHttpPort" can be used.

Is there any case not covered required by ]po[? Please check the new code.