Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-4746

"var contextPath" behind a Reverse proxy

    XMLWordPrintable

Details

    • Bug
    • Resolution: Outdated
    • Major
    • None
    • 4.4.8
    • admininterface
    • None
    • Magnolia Enterprise Edition on Tomcat 6

    Description

      We need to run Magnolia behind a Reverse proxy

      magnolia.properties:

      #magnolia.bootstrap.defaultBaseUrl=https://10.232.78.60/magnoliaPublic/
      magnolia.bootstrap.defaultBaseUrl=https://10.232.78.65/reverseproxy/cms/magnoliaPublic
      

      Now everything except the Admin Interface AJAX calls works correctly with this change:

      /.magnolia/pages/javascript.js :

      var contextPath = '/magnoliaPublic';
      /* ###################################
      ### i18n.js
      ################################### */
      
      info.magnolia.module.admininterface.pages.JavascriptIncludePage
          //...
          public void renderHtml(String view) throws IOException {
              HttpServletRequest request = getRequest();
              HttpServletResponse response = getResponse();
      
              PrintWriter out = response.getWriter();
              String contextPath = request.getContextPath();
      
              out.println("var contextPath = '" + contextPath + "';");
      
              prepareI18n(out);
      
              // finding files in classpath is too expensive, just cache the list of paths!
              String[] files = ClasspathResourcesUtil.findResources(new ClasspathResourcesUtil.Filter() {
                  public boolean accept(String name) {
                      return name.startsWith("/mgnl-resources/js-classes") && name.endsWith(".js");
                  }
              });
          //...
      

      To fix that I tried to read the DefaultBaseUrl from the config, that solved the most problems (except the 4 mgnlFunctionBar images):

      info.magnolia.module.admininterface.pages.JavascriptIncludePage
          //...
      
          public void renderHtml(String view) throws IOException {
              HttpServletRequest request = getRequest();
              HttpServletResponse response = getResponse();
      
              PrintWriter out = response.getWriter();
            
              // String contextPath = request.getContextPath();
              // get URI from "magnolia.bootstrap.defaultBaseUrl"
              String defaultBaseUrl = ServerConfiguration.getInstance().getDefaultBaseUrl();
              String contextPath = URI.create(defaultBaseUrl).getPath();
      
              out.println("var contextPath = '" + contextPath + "';");
      
          //...
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              dglanzmann Dan Glanzmann
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD