This discussion is archived
6 Replies Latest reply: Oct 15, 2012 10:30 AM by Patrick Wolf RSS

How can I set #HOST# variable referenced in the Chart template?

DonnaC-Houston Newbie
Currently Being Moderated
#HOST# and #HOST_PROTOCOL# are being set incorrectly by APEX from CGI variables when I create a chart. I am using APEX 4.1 and Oracle 11g. The get the continual "Loading data..." and then after it times out I get "Error loading file".

Before we changed to a secure http environment, our charts worked. After we changed to the new web layer, the charts do not work. The #HOST# substitution was set to http://correctservername/ and #HOST_PROTOCOL# was set to http. We set PlsqlCGIEnvironmentList REQUEST_PROTOCOL=https in the dads configuration file and now the #HOST# displays https but it also includes the default port number which we do not want (https://correctservername:port/) The charts work without the port. REQUEST_PROTOCOL is not in the cgi list and setting this variable set #HOST_PROTOCOL#. What variable can we set to make #HOST# correct. It seems like #HOST# is being set by #REQUEST_PROTOCOL#'://'||HTTP_HOST||':'||SERVER_PORT||SCRIPT_NAME||'/'. SERVER_NAME could also be used in of HTTP_HOST. I don't know how APEX is setting #HOST#. Does it come from a host alias somewhere in the environment?

I don't want to add a new cgi variable called HOST because HOST sounds so generic and it might interfere with something else running in our environment. Or, I don't want to change the plsql cgi environment variable (such as HTTP_HOST) because many developers may use owa_util.get_cgi_env('HTTP_HOST') to get the current server. If the SERVER_PORT is part of the #HOST# then what could I change it to if it needs to be null. If you leave it blank, then the default SERVER_PORT comes from the CGI variables.

I would rather not create a global variable (hard-coding) and create a new chart template using the global variable or create a before header application process to re-direct url without a port.

Edited by: Donna C-Houston on Oct 10, 2012 1:06 PM
  • 1. Re: How can I set #HOST# variable referenced in the Chart template?
    Patrick Wolf Employee ACE
    Currently Being Moderated
    Hi Donna,

    changing the CGI environment variables HTTP_HOST, REQUEST_PROTOCOL and SERVER_PORT is the correct way how to resolve this, because it appears that your hiding the web server where you have installed mod_plsql or EPG by a different outside facing web server (also called reverse proxy). That's why APEX gets the host name, protocol and port of the internal web server, but should actually get the values of your reverse proxy web server. Can can fix that by changing the following CGI environment variables.

    HTTP_HOST should just contain the domain name (no protocol or port). For example: www.oracle.com
    REQUEST_PROTOCOL should contain http or https
    SERVER_PORT should be the port for https
    I don't want to add a new cgi variable called HOST because HOST sounds so generic and it might interfere with something else running in our environment. Or, I don't want to change the plsql cgi environment variable (such as HTTP_HOST) because many developers may use owa_util.get_cgi_env('HTTP_HOST') to get the current server. If the SERVER_PORT is part of the #HOST# then what could I change it to if it needs to be null. If you leave it blank, then the default SERVER_PORT comes from the CGI variables.
    The value of HTTP_HOST is wrong anyway and points to your internal web server, but I assume your developers actually want to get the host name of your external web server if they use it to generate absolute URLs. That's why I wouldn't bother and set it to the correct host name.

    Regards
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf
  • 2. Re: How can I set #HOST# variable referenced in the Chart template?
    DonnaC-Houston Newbie
    Currently Being Moderated
    Thank you Patrick, for your response.

    Yes, the variables are set up correctly.

    Currently:
    HTTP_HOST is set to a valid domain name (without a protocol and port)
    REQUEST_PROTOCOL is set to https
    SERVER_PORT is set to the server port (number only)

    Before we set REQUEST_PROTOCOL, the value in #HOST# was http://domain/script and after we set REQUEST_PROTOCOL it now is https://domain:port/script. Notice how the port is displayed when we changed the protocol from http to https. Setting REQUEST_PROTOCOL did fix the #HOST_PROTOCOL# reference in the chart but #HOST# is still incorrect with the port in it.
  • 3. Re: How can I set #HOST# variable referenced in the Chart template?
    Patrick Wolf Employee ACE
    Currently Being Moderated
    Hi Donna,

    I think the reason why you see the port is the following snipped in our code to generate an absolute URL.
         if l_protocol = 'https' then
             l_host_url := replace(l_host_url,':443/','/');
         else
             l_host_url := replace(l_host_url,':80/','/');
         end if;
    Which will remove the port :443 if you are using HTTPS and :80 if you are using HTTP from the final URL, because these are the defaults for those protocols anyway.

    I assume you are still getting an invalid URL, because you still send port 80 in the environment variable SERVER_PORT, but you should actually set that to the 443 port used for the HTTPS protocol.

    Regards
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

    Edited by: Patrick Wolf on Oct 12, 2012 3:58 PM
  • 4. Re: How can I set #HOST# variable referenced in the Chart template?
    DonnaC-Houston Newbie
    Currently Being Moderated
    Thank you, Patrick. We changed the SERVER_PORT to 443 and it works great.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points