Using active reports web viewer behind a reverse proxy

Posted by: lshine on 14 September 2017, 10:08 am EST

    • Post Options:
    • Link

    Posted 14 September 2017, 10:08 am EST

    [activereports_archive]We upgraded to active reports 9 and we are having trouble using the report viewer behind our reverse proxy.

    When we try to load a report the iframe inside the report viewer ends up pointed to an internal URL.

    It seems like the ActiveReports.ReportService.asmx/GetExportedReportLink method is returning an absolute URL rather than a relative URL.

    Is there any way to make the URLs returned by ReportService.asmx relative rather than absolute, or alternatively is there a way of configuring the external URL that is being used by ReportService.asmx?

    [/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello,

    Regarding your original issue, “We upgraded to active reports 9 and we are having trouble using the report viewer behind our reverse proxy. When we try to load a report the iframe inside the report viewer ends up pointed to an internal URL.”,

    I would request you to please share the following :

    • stack trace of the error as observed at your end.
    • please share a screenshot depicting the error/issue

    Meanwhile I would request you to please try using the latest builds of AR9/AR10 and see if the issue still persists :

    AR9 SP5 : http://arhelp.grapecity.com/groups/topic/final-service-pack-for-activereports-9-released/

    AR10 SP1 : http://arhelp.grapecity.com/groups/topic/activereports-10-service-pack-1-released/

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello Reema,

    We have the same problem using AR9 SP5

    I have attached the screenshot using Microsoft Edge.

    Here is the stack trace:

    Regex

    Hide network messages

    All

    Errors

    Warnings

    Info

    Logs

    Debug

    Handled

    

    report.aspx?provider=681&report=713001:7 GET https://REDACTED/ProviderPortal/ActiveReports.ar9?Token=9…c10-c963f1c559ea&Command=Export&ExportType=Pdf&WebViewer=true&Generation=1 net::ERR_NAME_NOT_RESOLVED

    (anonymous function) @ report.aspx?provider=681&report=713001:7

    onAPICallSuccseeded @ Command=ArResource;ScriptId=RSU-9.1.2302.0.js.ar9:210

    (anonymous function) @ Command=ArResource;ScriptId=RSU-9.1.2302.0.js.ar9:310

    $.ajax.success @ Command=ArResource;ScriptId=RSU-9.1.2302.0.js.ar9:98

    o @ Command=ArResource;ScriptId=lib.jquery-1.7.2.min.js.ar9:2

    p.fireWith @ Command=ArResource;ScriptId=lib.jquery-1.7.2.min.js.ar9:2

    w @ Command=ArResource;ScriptId=lib.jquery-1.7.2.min.js.ar9:4

    d @ Command=ArResource;ScriptId=lib.jquery-1.7.2.min.js.ar9:4

    [/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello,

    I have escalated this issue to the development team(202480) for further review on this and will get back to you as soon as I get any information from their side regarding the same.

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello,

    It seems that your application was not correctly upgraded to the latest AR9 SP5 build : 9.5.6334.0 as we could see the references of AR9 SP1 build : 9.1.2302.0 in the stack trace that you have shared.



    onAPICallSuccseeded @ Command=ArResource;ScriptId=RSU-9.1.2302.0.js.ar9:210

    (anonymous function) @ Command=ArResource;ScriptId=RSU-9.1.2302.0.js.ar9:310

    $.ajax.success @ Command=ArResource;ScriptId=RSU-9.1.2302.0.js.ar9:98

    Please make sure that the application is correctly upgraded to the latest release and confirm if the issue still persists ? Clear the bin and obj folders → Clean and Rebuild the same.

    Share the new stack trace and the error messages if the issue still persists…

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello Reema,

    Has the behaviour of the service changed between version 9.1 and 9.5?

    I cannot update active reports on that server as it is on a client’s site.

    However when I use Fiddler or dev tools to intercept the communications between the browser and the server on version 9.5 it is still using the absolute URL when it is initialising the iframe, so I don’t think it is likely to solve the problem.

    Regards,

    Leo[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive](As in when I do a local build using AR 9.5 I see the absolute URL behaviour) [/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello,

    We will get back to you soon on this one.

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello,

    Here is a solution as suggested by the development team :

    Use jQuery.ajaxPrefilter(http://api.jquery.com/jquery.ajaxprefilter/) func in order to override the url of each ajax request so that it would always send requests to the target proxy server, here is the sample of the code:

    $.ajaxPrefilter(function( options ) {

    options.url = “http://192.168.103.6/” + encodeURIComponent( options.url );

    });

    this code is to be hosted in the html page that shows html5/Web viewer and to be called in document.onload

    The options.url handling might be more complex - it needs to parse the protocol, host, post and the address and then build the new url.

    However, that’s pretty basic JS stuff, which you will understand easily.

    Please refer to the attached sample implementing the above solution in case of an HTML5Viewer.

    Please note : You can use same redirection code as HTML5 viewer uses because both WebViewer and HTML5Viewer use the same service.

    Hope this helps.

    Regards,

    Reema[/activereports_archive]

    2016/04/ReverseProxyIssue.zip

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hi Reema,

    I don’t understand why that would help. The ajax requests are happening fine, the problem is the URL returned by the AJAX request that is being used in the iframe in the report viewer.

    The short term solution we have been using is to intercept the creation of the iframe to make it point to the local rather than the absolute URL

    like this

        (function () {
    
            function getLocalPath(url) {
                var a = document.createElement('a');
                a.href = url;
    
                return a.pathname + a.search;
            }
    
            console.log("Monkey patching ");
            var createElementUnpatched = document.createElement;
    
    
            var correctIframeUri = function (iframe) {
                console.log("Correcting url for iframe with src: " + iframe.src);
                var oldSrc = iframe.src;
    
                var newSrc = getLocalPath(oldSrc);
                console.log("Replaced with " + newSrc);
                iframe.src = newSrc;
            };
    
            var newCreateElement = function () {
    
                console.log("intercepting create for " + arguments[0]);
    
                var result = createElementUnpatched.apply(this, arguments);
                if (arguments[0] === "iframe") {
                    setTimeout(function () { correctIframeUri(result) });
                }
                return result;
            }
    
            document.createElement = newCreateElement;
    
        })();
    

    Obviously we don’t want to use this in the long term as it is doing nasty stuff in the browser and could be very brittle to changes in the way that the reports are constructed by Active Reports.

    The underlying problem is that an absolute URL is being returned from the GetExportedReportLink method.

    Kind regards,

    Leo

    [/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello Leo,

    I have again asked the development team to look into this issue further and we will get back to you asap.

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello,

    In order to change the url returned by the AJAX request being used in the reportviewer, you need to use the code that was suggested earlier :

    [js] $.ajaxPrefilter(function (options, originalOptions, jqXHR) {

    if (options.type == “GET” && options.url.startsWith(‘http://’))

    options.url = options.url.replace(‘http://’, ‘https://’);

    });[/js]

    Modify the code above as follows :

    • replace the text ‘https://’ with the relative url (i.e., url returned from getLocalPath method) and
    • replace the text ‘http://’ with the absolute url

    This is just an example, you would need to modify the code as per your requirement.

    Hope this helps.

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hi Reema,

    I have run this against active reports version 9.5.6334 and it does not solve the problem.

    The reason why this doesn’t solve the problem is that the ajax calls were already succeeding as they are using a relative URL, unfortunately the GetExportedReportLink ajax call returns an absolute URL as part of the JSON it returns. This is then used as the src of the iframe for the report, however this causes the problem as the report link is behind the reverse proxy.

    I would be happy to have a chat to one of your developers if they would like me to explain the problem to them directly. I am happy to be emailed directly to organise this.

    Kind regards,

    Leo

    [/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello Leo,

    I have escalated the issue again to the development team and we will update you soon.

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Thank you.[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello Leo,

    Please review the hotfix on the below link that fixes your issue and share your observations :

    http://cdn.grapecity.com/ActiveReports/ar9/hotfixes/ActiveReports-v9.5.7547.0.msi

    Regards,

    Reema[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello Reema,

    Thank you for getting back to me about this.

    I have tested this using the new hotfix installer and it now does not cause the same issues as we were seeing before.

    Kind regards,

    Leo[/activereports_archive]

  • Posted 14 September 2017, 10:08 am EST

    [activereports_archive]Hello,

    Glad to hear that the hotfix worked for you. We will close this case in our system.

    Let us know if there is anything else we can help you with.

    Regards,

    Reema

    [/activereports_archive]

  • Posted 7 October 2018, 11:27 pm EST

    Hi, Thank you for this information at first i got the same issue with 9.1 but when i upgrade it to 9.5 the issue is fix. You just need to upgrade it correctly to 9.5 something…

    Thank you… 19216811.zone

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels