Uploaded image for project: 'Service Packs and Hot Fixes'
  1. Service Packs and Hot Fixes
  2. MNT-16463

400 Bad Request: AOS webdav MOVE fails when a port redirection is applied

    Details

    • Type: Service Pack Request
    • Status: Closed (View Workflow)
    • Resolution: Not a bug
    • Affects Version/s: 5.0.2
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      any
    • Bug Priority:
      Category 1
    • ACT Numbers:

      00681143

      Description

      How to reproduce?
      ===================

      1) create a 5.0.2 plain vanilla system (linux pg tomcat)
      2) as 'admin', create a site 'site1'
      3) as 'admin', in 'site1' documentLibrary upload a file 'test1.txt'
      4) confirm you can see the file using curl:

      curl -v --user admin:admin http://localhost:8080/alfresco/aos/Sites/site1/documentLibrary/
      

      5) confirm you can MOVE (rename) the file using curl:

      curl -v --user admin:admin \
      -X MOVE \
      -H "Destination: http://127.0.0.1:8080/alfresco/aos/Sites/site1/documentLibrary/test2.txt" \
      http://127.0.0.1:8080/alfresco/aos/Sites/site1/documentLibrary/test1.txt
      ....
      < HTTP/1.1 201 Created
      ....
      

      6) check in share that the file has been renamed into 'test2.txt', and then rename it back using the web UI to 'test1.txt'

      7) apply an iptables rule that redirects port 80 to port 8080:

      iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080
      

      8) confirm you can navigate in share using a browser on port 80:
      http://localhost/share

      9) try to rename again the file 'test1.txt' into 'test2.txt' using the MOVE as before but this time on port 80:

      curl -v --user admin:admin \
      -X MOVE \
      -H "Destination: http://127.0.0.1/alfresco/aos/Sites/site1/documentLibrary/test2.txt" \
      http://127.0.0.1/alfresco/aos/Sites/site1/documentLibrary/test1.txt
      

      Results
      ========
      The MOVE fails with a

      HTTP/1.1 400 Bad Request
      

      and within the HTML payload the message:

      The request sent by the client was syntactically incorrect.
      

      Here is the full HTTP conversation:

      curl -v --user admin:admin \
      > -X MOVE \
      > -H "Destination: http://127.0.0.1/alfresco/aos/Sites/site1/documentLibrary/test2.txt" \
      > http://127.0.0.1/alfresco/aos/Sites/site1/documentLibrary/test1.txt
      > MOVE /alfresco/aos/Sites/site1/documentLibrary/test1.txt HTTP/1.1
      > Authorization: Basic YWRtaW46YWRtaW4=
      > User-Agent: curl/7.38.0
      > Host: 127.0.0.1
      > Accept: */*
      > Destination: http://127.0.0.1/alfresco/aos/Sites/site1/documentLibrary/test2.txt
      > 
      < HTTP/1.1 400 Bad Request
      < Server: Apache-Coyote/1.1
      < Set-Cookie: JSESSIONID=4A56AA5AA2756AB4890EF34069BD5B17; Path=/alfresco/; HttpOnly
      < MS-Author-Via: MS-FP/4.0,DAV
      < MicrosoftOfficeWebServer: 5.0_Collab
      < DocumentManagementServer: Properties Schema;Source Control;Version History;
      < DAV: 1,2
      < Allow: GET, POST, OPTIONS, HEAD, MKCOL, PUT, PROPFIND, PROPPATCH, DELETE, MOVE, COPY, GETLIB, LOCK, UNLOCK
      < Accept-Ranges: none
      < Content-Type: text/html;charset=utf-8
      < Content-Language: en
      < Content-Length: 968
      < Date: Fri, 24 Jun 2016 12:38:02 GMT
      < Connection: close
      < 
      <html><head><title>Apache Tomcat/7.0.52 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The request sent by the client was syntactically incorrect.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.52</h3></body></html>
      

      In the logs with also observe an error:

      2016-06-24 14:38:02,566  ERROR [xoservices-err.StandardWebdavService] [http-bio-8080-exec-14] doMove: BAD REQUEST: Destination malformed
      

      Expected results
      =================
      The MOVE should work.

      Notes
      =======
      1) the error messages are not clear on why we refuse the request. I have logged a separate Jira for this: MNT-16464
      2) it seems that the AOS stack is more picky than the webdav stack about MOVE. In this case the probable "reason" for refusing the request is because the server believes that localhost:8080 and localhost:80 and two different servers and does not detect the port redirection.
      3) similar to ACE-2362 where Alfresco was confused by white-spaces instead of port redirects.
      4) this can also be seen when mapping a drive to AOS as per the documentation
      http://docs.alfresco.com/aos1.1/concepts/aos-user.html
      and then doing the rename using MS File Explorer.
      5) there is a discrepancy between AOS and webdav. Indeed, if in the command above to port 80, we replace /alfresco/aos by /alfresco/webdav, the MOVE works

      curl -v --user admin:admin \
      -X MOVE \
      -H "Destination: http://127.0.0.1/alfresco/webdav/Sites/site1/documentLibrary/test2.txt" \
      http://127.0.0.1/alfresco/webdav/Sites/site1/documentLibrary/test1.txt
      
      < HTTP/1.1 201 Created
      

      6) redirecting port 80 to 8080 using iptables is not something too uncommon, as we even document it, see eg:
      http://docs.alfresco.com/5.0/tasks/configure-ssl-test.html

      7) workaround:
      setting in alfresco-global.properties:

      aos.baseUrlOverwrite=http://127.0.0.1/alfresco/aos
      

      make the command:

      curl -v --user admin:admin \
      -X MOVE \
      -H "Destination: http://127.0.0.1/alfresco/aos/Sites/site1/documentLibrary/test2.txt" \
      http://127.0.0.1/alfresco/aos/Sites/site1/documentLibrary/test1.txt
      

      accepted.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                closedissues Closed Issues
                Reporter:
                amadon Alex Madon [X] (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 40 minutes
                  2h 40m