Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-10701

ServletUriComponentsBuilder doesn't work if X-Forwarded-Host is in host:port format

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.2.1
    • Fix Version/s: 3.2.4, 4.0 M3
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      Linked with SPR-10110
      ServletUriComponentsBuilder takes X-Forwarded-Host value from header (if exists) and puts it as "host".
      If X-Forwarded-Host is:
      X-Forwarded-Host: webtest.foo.bar.com:443

      creating uri produces error:

      org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Could not create URI object: Malformed IPv6 address at index 8: http://[webtest.foo.bar.com:443]:8180/api/person/449089
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
      ...

      Definition of Host header:
      http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23

      X-Forwarded-Host is a copy of Host header:
      http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#x-headers

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rstoya05-aop Rossen Stoyanchev
                Reporter:
                hrvojej Hrvoje Jambrovic
                Last updater:
                Spring Issuemaster
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  26 weeks, 3 days ago