Uploaded image for project: 'GeoServer'
  1. GEOS-8240

Support X-Forwarded-Proto header in ResponseUtils.baseURL

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 2.11.1
    • Fix Version/s: 2.14.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Ubuntu 16.04 + nginx + tomcat8

      Description

      https://github.com/geoserver/geoserver/blob/master/src/ows/src/main/java/org/geoserver/ows/util/ResponseUtils.java#L427
      ResponseUtils.baseURL use req.getScheme() but if tomcat run http and run inside SSL proxy server, req.getScheme() return "http".
      This problem raise mix-contents error in Layer Preview in Style Editor.
      This problem will resolve to check "X-Forwarded-Proto" header.

      example:

      String scheme = req.getScheme();
      String proto = req.getHeader("x-forwarded-proto");
      StringBuffer sb = new StringBuffer();
      if (proto.equals("https") && !scheme.equals(proto)) {
        sb.append(proto);
      } else {
        sb.append(scheme);
      }
      

      nginx config example:

        location ~* ^/geoserver/(.*) {
          proxy_set_header X-Forwarded-Proto https;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_pass http://127.0.0.1:8080;
        }
      

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                taro Taro Matsuzawa
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: