Caddy: PANIC : invalid WriteHeader code 0

Created on 12 Apr 2018  Â·  12Comments  Â·  Source: caddyserver/caddy

Caddy 0.10.12 (unofficial)

use caddy with php-fpm

Caddyfile

xxxx:9098
tls off
gzip
root /data/
fastcgi / 127.0.0.1:9000 php

the backend is nextcloud run in php-fpm
the broswer send PROPFIND request to http://xxxx:9098/remote.php/webdav/

curl 'http://xxxx:9098/remote.php/webdav/' -X PROPFIND -H 'Cookie: nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n' -H 'requesttoken: 7Bct7jj7T4e8w4tvDorcdG2F8IwcA0gE/6N4sO0SJGA=:mlVktlKhfL79+t4qOLy+Ez7fxM0tdQBBk9Yc55oiCwc=' -H 'Origin: http://xxxx:9098' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36' -H 'Content-Type: application/xml; charset=UTF-8' -H 'Accept: */*' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'Depth: 1' --data-binary $'<?xml version="1.0"?>\n<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">\n  <d:prop>\n    <d:getlastmodified />\n    <d:getetag />\n    <d:getcontenttype />\n    <d:resourcetype />\n    <oc:fileid />\n    <oc:permissions />\n    <oc:size />\n    <d:getcontentlength />\n    <nc:has-preview />\n    <nc:mount-type />\n    <oc:tags />\n    <oc:favorite />\n    <oc:comments-unread />\n    <oc:owner-display-name />\n    <oc:share-types />\n  </d:prop>\n</d:propfind>' --compressed
curl: (61) Error while processing content unencoding: invalid code lengths set

caddy logs PANIC and broswer got 500 Internal Server Error

12/Apr/2018:07:46:31 +0000 [PANIC /remote.php/webdav/] /usr/local/go/src/net/http/server.go:1070 - invalid WriteHeader code 0

bug good first issue help wanted

Most helpful comment

/datawebdav/ is because this happens:

https://github.com/mholt/caddy/blob/ca34a3e1aa21c767322f9275c2281df96a3eb402/caddyhttp/fastcgi/fastcgi.go#L323

root is /data and pathInfo is webdav/ the they join into /datawebdav/

Now the pathinfo is assigned here:
https://github.com/mholt/caddy/blob/ca34a3e1aa21c767322f9275c2281df96a3eb402/caddyhttp/fastcgi/fastcgi.go#L267

Mybe there is an overlap when we splitting the strings to paths so the env gets populated wrong, I'm not sure.

For this request to /remote.php/webdav/ the values should be:

script_name = /remote.php
path_info= /webdav/

All 12 comments

Apparently fastcgi is sending back an error but not propagating an error code back through the middleware chain (it should be returning http.StatusInternalServerError but it's returning 0). I'm swamped, but this would be a good issue for someone new to the project to investigate.

@suconghou is it possible to get a stack trace for this?

@theodesp there is no stack trace in caddy's log 。
I use ngrep captured some request data

from chrome to caddy server


T 127.0.0.1:57563 -> 127.0.0.1:9098 [AP] #9
PROPFIND /remote.php/webdav/ HTTP/1.1.
Host: xmpp.git.suconghou.cn:9098.
Connection: keep-alive.
Content-Length: 493.
requesttoken: WCxlhVt7JMwO7hc6SBZx5iDh5AKcu+7FCGlkuVGc/BA=:LUYW1xcBFIY7unltIFVBk0Ol0zfo0tuXUSsB8AX0hFo=.
Origin: http://xmpp.git.suconghou.cn:9098.
X-Requested-With: XMLHttpRequest.
Content-Type: application/xml; charset=UTF-8.
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36.
Depth: 1.
Accept: */*.
Accept-Encoding: gzip, deflate.
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8.
Cookie: nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n.
.


T 127.0.0.1:57563 -> 127.0.0.1:9098 [AP] #10
PROPFIND /remote.php/webdav/ HTTP/1.1.
Host: xmpp.git.suconghou.cn:9098.
Connection: keep-alive.
Content-Length: 493.
requesttoken: WCxlhVt7JMwO7hc6SBZx5iDh5AKcu+7FCGlkuVGc/BA=:LUYW1xcBFIY7unltIFVBk0Ol0zfo0tuXUSsB8AX0hFo=.
Origin: http://xmpp.git.suconghou.cn:9098.
X-Requested-With: XMLHttpRequest.
Content-Type: application/xml; charset=UTF-8.
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36.
Depth: 1.
Accept: */*.
Accept-Encoding: gzip, deflate.
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8.
Cookie: nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n.
.


T 127.0.0.1:57563 -> 127.0.0.1:9098 [AP] #11
<?xml version="1.0"?>
<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
    <d:getlastmodified />
    <d:getetag />
    <d:getcontenttype />
    <d:resourcetype />
    <oc:fileid />
    <oc:permissions />
    <oc:size />
    <d:getcontentlength />
    <nc:has-preview />
    <nc:mount-type />
    <oc:tags />
    <oc:favorite />
    <oc:comments-unread />
    <oc:owner-display-name />
    <oc:share-types />
  </d:prop>
</d:propfind>

T 127.0.0.1:57563 -> 127.0.0.1:9098 [AP] #13
<?xml version="1.0"?>
<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
    <d:getlastmodified />
    <d:getetag />
    <d:getcontenttype />
    <d:resourcetype />
    <oc:fileid />
    <oc:permissions />
    <oc:size />
    <d:getcontentlength />
    <nc:has-preview />
    <nc:mount-type />
    <oc:tags />
    <oc:favorite />
    <oc:comments-unread />
    <oc:owner-display-name />
    <oc:share-types />
  </d:prop>
</d:propfind>

T 127.0.0.1:9098 -> 127.0.0.1:57563 [AP] #21
HTTP/1.1 500 Internal Server Error.
Cache-Control: no-store, no-cache, must-revalidate.
Content-Encoding: gzip.
Content-Security-Policy: default-src 'none';.
Content-Type: text/plain; charset=utf-8.
Expires: Thu, 19 Nov 1981 08:52:00 GMT.
Pragma: no-cache.
Server: Caddy.
Status: 0.
Vary: Accept-Encoding.
X-Content-Type-Options: nosniff.
X-Download-Options: noopen.
X-Frame-Options: SAMEORIGIN.
X-Permitted-Cross-Domain-Policies: none.
X-Robots-Tag: none.
X-Xss-Protection: 1; mode=block.
Date: Fri, 20 Apr 2018 06:35:08 GMT.
Content-Length: 49.
.
500 Internal Server Error
.........?...??........

T 127.0.0.1:9098 -> 127.0.0.1:57563 [AP] #22
HTTP/1.1 500 Internal Server Error.
Cache-Control: no-store, no-cache, must-revalidate.
Content-Encoding: gzip.
Content-Security-Policy: default-src 'none';.
Content-Type: text/plain; charset=utf-8.
Expires: Thu, 19 Nov 1981 08:52:00 GMT.
Pragma: no-cache.
Server: Caddy.
Status: 0.
Vary: Accept-Encoding.
X-Content-Type-Options: nosniff.
X-Download-Options: noopen.
X-Frame-Options: SAMEORIGIN.
X-Permitted-Cross-Domain-Policies: none.
X-Robots-Tag: none.
X-Xss-Protection: 1; mode=block.
Date: Fri, 20 Apr 2018 06:35:08 GMT.
Content-Length: 49.
.
500 Internal Server Error
.........?...??........

from caddy server to php-fpm on port 9000

T 127.0.0.1:34204 -> 127.0.0.1:9000 [AP]
................

T 127.0.0.1:34204 -> 127.0.0.1:9000 [AP]
.....t..
.HTTP_DEPTH1..REMOTE_IDENT..SCRIPT_FILENAME/data/remote.php/webdav..SCRIPT_NAME/remote.php.....HTTP_COOKIEnc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n..SERVER_NAMExmpp.git.suconghou.cn..SERVER_SOFTWARECaddy/0.10.14.
REMOTE_ADDR172.17.0.1.
REMOTE_HOST172.17.0.1..DOCUMENT_URI/remote.php..REQUEST_URI/remote.php/webdav/..PATH_TRANSLATED/data/webdav.!HTTP_ORIGINhttp://xmpp.git.suconghou.cn:9098..HTTP_X_REQUESTED_WITHXMLHttpRequest..CONTENT_LENGTH493..REQUEST_METHODPROPFIND..HTTP_ACCEPT*/*..GATEWAY_INTERFACECGI/1.1..SERVER_PORT9098..AUTH_TYPE..DOCUMENT_ROOT/data..REMOTE_PORT37608..SERVER_PROTOCOLHTTP/1.1.
HTTP_CONNECTIONkeep-alive.yHTTP_USER_AGENTMozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36..HTTP_CONTENT_LENGTH493.YHTTP_REQUESTTOKENWCxlhVt7JMwO7hc6SBZx5iDh5AKcu+7FCGlkuVGc/BA=:LUYW1xcBFIY7unltIFVBk0Ol0zfo0tuXUSsB8AX0hFo=..CONTENT_TYPEapplication/xml; charset=UTF-8..PATH_INFO/webdav/..HTTP_CONTENT_TYPEapplication/xml; charset=UTF-8..HTTP_HOSTxmpp.git.suconghou.cn:9098..HTTP_ACCEPT_ENCODINGgzip, deflate..HTTP_ACCEPT_LANGUAGEzh-CN,zh;q=0.9,en;q=0.8..QUERY_STRING..REMOTE_USER....

T 127.0.0.1:34204 -> 127.0.0.1:9000 [AP]
........

T 127.0.0.1:34204 -> 127.0.0.1:9000 [AP]
........<?xml version="1.0"?>
<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
    <d:getlastmodified />
    <d:getetag />
    <d:getcontenttype />
    <d:resourcetype />
    <oc:fileid />
    <oc:permissions />
    <oc:size />
    <d:getcontentlength />
    <nc:has-preview />
    <nc:mount-type />
    <oc:tags />
    <oc:favorite />
    <oc:comments-unread />
    <oc:owner-display-name />
    <oc:share-types />
  </d:prop>
</d:propfind>...

T 127.0.0.1:34204 -> 127.0.0.1:9000 [AP]
........

T 127.0.0.1:9000 -> 127.0.0.1:34204 [AP]
.....%..Status: 0.
Expires: Thu, 19 Nov 1981 08:52:00 GMT.
Cache-Control: no-store, no-cache, must-revalidate.
Pragma: no-cache.
X-Frame-Options: SAMEORIGIN.
X-XSS-Protection: 1; mode=block.
X-Content-Type-Options: nosniff.
X-Robots-Tag: none.
X-Download-Options: noopen.
X-Permitted-Cross-Domain-Policies: none.
Content-Security-Policy: default-src 'none';.
Content-type: text/html; charset=UTF-8.
.
<!DOCTYPE html>
<html class="ng-csp" data-placeholder-focus="false" lang="zh_CN" >
.<head data-requesttoken="">
..<meta charset="utf-8">
..<title>
..Nextcloud..</title>
..<meta http-equiv="X-UA-Compatible" content="IE=edge">
..<meta name="referrer" content="never">
..<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
..<meta name="apple-itunes-app" content="app-id=1125420102">
..<meta name="theme-color" content="#0082c9">
..<link rel="icon" href="/core/img/favicon.ico">
..<link rel="apple-touch-icon-precomposed" href="/core/img/favicon-touch.png">
..<link rel="mask-icon" sizes="any" href="/core/img/favicon-mask.svg" color="#0082c9">
.......<link rel="stylesheet" href="/core/vendor/select2/select2.css?v=5ac891842ec2652d6a14ebf14ddeb344-0">
.....<link rel="stylesheet" href="/index.php/css/core/6991c58504009c6b63c7bef0fee5c22e-server.css?v=5ac891842ec2652d6a14ebf14ddeb344-0">
.....<link rel="stylesheet" href="/core/vendor/jquery-ui/themes/base/jquery-ui.css?v=5ac891842ec2652d6a14ebf14ddeb344-0">
.....<link rel="stylesheet" href="/core/css/jquery-ui-fixes.css?v=5ac891842ec2652d6a14ebf14ddeb344-0">
.....<link rel="stylesheet" href="/index.php/css/core/6991c58504009c6b63c7bef0fee5c22e-share.css?v=5ac891842ec2652d6a14ebf14ddeb344-0">
.....<link rel="stylesheet" href="/apps/files_versions/css/versions.css?v=5ac891842ec2652d6a14ebf14ddeb344-0">
.....<link rel="stylesheet" href="/core/css/jquery.ocdialog.css?v=5ac891842ec2652d6a14ebf14ddeb344-0">
.........<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/core/vendor/core.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/index.php/js/core/merged-template-prepend.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/core/search/js/search.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/core/l10n/zh_CN.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/index.php/js/core/merged-share-backend.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/core/js/jquery-ui-fixes.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/core/js/files/fileinfo.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/core/js/files/client.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
.....<script nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0=" src="/core/js/contactsmenu.js?v=5ac891842ec2652d6a14ebf14ddeb344-0"></script>
....<link rel="stylesheet" href="/index.php/apps/theming/styles?v=0"/><script src="/index.php/apps/theming/js/theming?v=0" nonce="ZGpZL244ekR1NmtvYXlucFVmS2tBZGNJbjNoWTNHWUxsTmlrWGl6OERxaz06QTF4TXpZQzVpK01kUDBlK09iR1VkTFJNcUUwc3RWTlp6WnJCRjNpVWR1TT0="></script>.</head>
.<body id="body-login">
..<noscript>
.<div id="nojavascript">
..<div>
........................, ..................... JavaScript. ... <a href="http://enable-javascript.com/" target="_blank" rel="noreferrer">...... JavaScript</a>, ........................</div>
.</div>
</noscript>
..<div class="wrapper">
...<div class="v-align">
.........<header role="banner">
......<div id="header">
.......<div class="logo">
........<h1 class="hidden-visually">
.........Nextcloud........</h1>
...............</div>
.......<div id="logo-claim" style="display:none;"></div>
......</div>
.....</header>
........<ul class="error-wide">
...<li class='error'>
...App not installed: <br>
.....</li>
.</ul>
....<div class="push"></div><!-- for sticky footer -->
...</div>
..</div>
..<footer role="contentinfo">
...<p class="info">
....<a href="https://nextcloud.com" target="_blank" rel="noreferrer">Nextcloud</a> ... ..........................................</p>
..</footer>
.</body>
</html>
...................

and I use php -S 0.0.0.0:9098 replace the caddy server and php-fpm

from chrome to php build-in server

T 127.0.0.1:59033 -> 127.0.0.1:9098 [AP] #9
PROPFIND /remote.php/webdav/ HTTP/1.1.
Host: xmpp.git.suconghou.cn:9098.
Connection: keep-alive.
Content-Length: 493.
requesttoken: WCxlhVt7JMwO7hc6SBZx5iDh5AKcu+7FCGlkuVGc/BA=:LUYW1xcBFIY7unltIFVBk0Ol0zfo0tuXUSsB8AX0hFo=.
Origin: http://xmpp.git.suconghou.cn:9098.
X-Requested-With: XMLHttpRequest.
Content-Type: application/xml; charset=UTF-8.
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36.
Depth: 1.
Accept: */*.
Accept-Encoding: gzip, deflate.
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8.
Cookie: nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n.
.


T 127.0.0.1:59033 -> 127.0.0.1:9098 [AP] #10
<?xml version="1.0"?>
<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
    <d:getlastmodified />
    <d:getetag />
    <d:getcontenttype />
    <d:resourcetype />
    <oc:fileid />
    <oc:permissions />
    <oc:size />
    <d:getcontentlength />
    <nc:has-preview />
    <nc:mount-type />
    <oc:tags />
    <oc:favorite />
    <oc:comments-unread />
    <oc:owner-display-name />
    <oc:share-types />
  </d:prop>
</d:propfind>

T 127.0.0.1:59033 -> 127.0.0.1:9098 [AP] #11
PROPFIND /remote.php/webdav/ HTTP/1.1.
Host: xmpp.git.suconghou.cn:9098.
Connection: keep-alive.
Content-Length: 493.
requesttoken: WCxlhVt7JMwO7hc6SBZx5iDh5AKcu+7FCGlkuVGc/BA=:LUYW1xcBFIY7unltIFVBk0Ol0zfo0tuXUSsB8AX0hFo=.
Origin: http://xmpp.git.suconghou.cn:9098.
X-Requested-With: XMLHttpRequest.
Content-Type: application/xml; charset=UTF-8.
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36.
Depth: 1.
Accept: */*.
Accept-Encoding: gzip, deflate.
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8.
Cookie: nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n.
.


T 127.0.0.1:59033 -> 127.0.0.1:9098 [AP] #13
<?xml version="1.0"?>
<d:propfind  xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
  <d:prop>
    <d:getlastmodified />
    <d:getetag />
    <d:getcontenttype />
    <d:resourcetype />
    <oc:fileid />
    <oc:permissions />
    <oc:size />
    <d:getcontentlength />
    <nc:has-preview />
    <nc:mount-type />
    <oc:tags />
    <oc:favorite />
    <oc:comments-unread />
    <oc:owner-display-name />
    <oc:share-types />
  </d:prop>
</d:propfind>

T 127.0.0.1:9098 -> 127.0.0.1:59033 [AP] #21
HTTP/1.1 207 Multi-Status.
Host: xmpp.git.suconghou.cn:9098.
Date: Fri, 20 Apr 2018 06:41:13 +0000.
Connection: close.
Expires: Thu, 19 Nov 1981 08:52:00 GMT.
Cache-Control: no-store, no-cache, must-revalidate.
Pragma: no-cache.
X-Frame-Options: SAMEORIGIN.
X-XSS-Protection: 1; mode=block.
X-Content-Type-Options: nosniff.
X-Robots-Tag: none.
X-Download-Options: noopen.
X-Permitted-Cross-Domain-Policies: none.
Content-Security-Policy: default-src 'none';.
Content-Type: application/xml; charset=utf-8.
Vary: Brief,Prefer.
DAV: 1, 3, extended-mkcol.
.
<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/webdav/</d:href><d:propstat><d:prop><d:getlastmodified>Thu, 12 Apr 2018 07:54:57 GMT</d:getlastmodified><d:getetag>&quot;5acf10cf6b6a9&quot;</d:getetag><d:resourcetype><d:collection/></d:resourcetype><oc:fileid>24</oc:fileid><oc:permissions>RDNVCK</oc:permissions><oc:size>42976</oc:size><nc:has-preview>false</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:getcontenttype/><d:getcontentlength/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response><d:response><d:href>/remote.php/webdav/test/</d:href><d:propstat><d:prop><d:getlastmodified>Thu, 12 Apr 2018 07:55:23 GMT</d:getlastmodified><d:getetag>&quot;5acf10cf6b6a9&quot;</d:getetag><d:resourcetype><d:collection/></d:resourcetype><oc:fileid>207</oc:fileid><oc:permissions>RDNVCK</oc:permissions><oc:size>40766</oc:size><nc:has-preview>false</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:getcontenttype/><d:getcontentlength/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response><d:response><d:href>/remote.php/webdav/welcome.txt</d:href><d:propstat><d:prop><d:getlastmodified>Mon, 12 Mar 2018 09:36:30 GMT</d:getlastmodified><d:getetag>&quot;9bfa2971cbf5f535b466d45006bc1f61&quot;</d:getetag><d:getcontenttype>text/plain</d:getcontenttype><d:resourcetype/><oc:fileid>25</oc:fileid><oc:permissions>RDNVW</oc:permissions><oc:size>164</oc:size><d:getcontentlength>164</d:getcontentlength><nc:has-preview>true</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/webdav/%e6%96%b0%e5%bb%ba%e6%96%87%e4%bb%b6%e5%a4%b9/</d:href><d:propstat><d:prop><d:getlastmodified>Wed, 11 Apr 2018 13:37:40 GMT</d:getlastmodified><d:getetag>&quot;5ace0fa430990&quot;</d:getetag><d:resourcetype><d:collection/></d:resourcetype><oc:fileid>189</oc:fileid><oc:permissions>RDNVCK</oc:permissions><oc:size>2046</oc:size><nc:has-preview>false</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types><oc:share-type>3</oc:share-type></oc:share-types></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:getcontenttype/><d:getcontentlength/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>

T 127.0.0.1:9098 -> 127.0.0.1:59033 [AP] #22
HTTP/1.1 207 Multi-Status.
Host: xmpp.git.suconghou.cn:9098.
Date: Fri, 20 Apr 2018 06:41:13 +0000.
Connection: close.
Expires: Thu, 19 Nov 1981 08:52:00 GMT.
Cache-Control: no-store, no-cache, must-revalidate.
Pragma: no-cache.
X-Frame-Options: SAMEORIGIN.
X-XSS-Protection: 1; mode=block.
X-Content-Type-Options: nosniff.
X-Robots-Tag: none.
X-Download-Options: noopen.
X-Permitted-Cross-Domain-Policies: none.
Content-Security-Policy: default-src 'none';.
Content-Type: application/xml; charset=utf-8.
Vary: Brief,Prefer.
DAV: 1, 3, extended-mkcol.
.
<?xml version="1.0"?>
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/webdav/</d:href><d:propstat><d:prop><d:getlastmodified>Thu, 12 Apr 2018 07:54:57 GMT</d:getlastmodified><d:getetag>&quot;5acf10cf6b6a9&quot;</d:getetag><d:resourcetype><d:collection/></d:resourcetype><oc:fileid>24</oc:fileid><oc:permissions>RDNVCK</oc:permissions><oc:size>42976</oc:size><nc:has-preview>false</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:getcontenttype/><d:getcontentlength/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response><d:response><d:href>/remote.php/webdav/test/</d:href><d:propstat><d:prop><d:getlastmodified>Thu, 12 Apr 2018 07:55:23 GMT</d:getlastmodified><d:getetag>&quot;5acf10cf6b6a9&quot;</d:getetag><d:resourcetype><d:collection/></d:resourcetype><oc:fileid>207</oc:fileid><oc:permissions>RDNVCK</oc:permissions><oc:size>40766</oc:size><nc:has-preview>false</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:getcontenttype/><d:getcontentlength/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response><d:response><d:href>/remote.php/webdav/welcome.txt</d:href><d:propstat><d:prop><d:getlastmodified>Mon, 12 Mar 2018 09:36:30 GMT</d:getlastmodified><d:getetag>&quot;9bfa2971cbf5f535b466d45006bc1f61&quot;</d:getetag><d:getcontenttype>text/plain</d:getcontenttype><d:resourcetype/><oc:fileid>25</oc:fileid><oc:permissions>RDNVW</oc:permissions><oc:size>164</oc:size><d:getcontentlength>164</d:getcontentlength><nc:has-preview>true</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response><d:response><d:href>/remote.php/webdav/%e6%96%b0%e5%bb%ba%e6%96%87%e4%bb%b6%e5%a4%b9/</d:href><d:propstat><d:prop><d:getlastmodified>Wed, 11 Apr 2018 13:37:40 GMT</d:getlastmodified><d:getetag>&quot;5ace0fa430990&quot;</d:getetag><d:resourcetype><d:collection/></d:resourcetype><oc:fileid>189</oc:fileid><oc:permissions>RDNVCK</oc:permissions><oc:size>2046</oc:size><nc:has-preview>false</nc:has-preview><nc:mount-type></nc:mount-type><oc:tags/><oc:favorite>0</oc:favorite><oc:comments-unread>0</oc:comments-unread><oc:owner-display-name>ivygate</oc:owner-display-name><oc:share-types><oc:share-type>3</oc:share-type></oc:share-types></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat><d:propstat><d:prop><d:getcontenttype/><d:getcontentlength/></d:prop><d:status>HTTP/1.1 404 Not Found</d:status></d:propstat></d:response></d:multistatus>

It works fine , and nginx with php-fpm also works fine.

so It must be caddy's perblom, maybe the fastcgi module

hope these will help you.

Status: 0 is not valid status code so the internal go server panics here:
https://github.com/golang/go/blob/1f5a0e8ccd7043df8457dd7822c10fe83f6b2a65/src/net/http/server.go#L1070

So I'm wondering what is the origin of this Status code. Will investigate

@theodesp I found the problem !

when use php-fpm with nginx with config

 location ~ [^/]\.php(/|$) {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }

nginx response with 404 and show the not found html like above

when nginx use config

 location ~ [^/]\.php(/|$) {
            fastcgi_pass   127.0.0.1:9000;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }

nginx works well just like php build-in server and response 207 with xml

when use caddy with config

xxxx:9098
tls off
gzip
root /data/
fastcgi / 127.0.0.1:9000 php

I logs invalid WriteHeader code 0.

the key is path_info passed to php-fpm .

nginx without use fastcgi_split_path_info ^(.+\.php)(/.+)$; , php-fpm return 404 and with not found html, I capture the php-fpm response, it is really 404 not 0;

caddy passed wrong path_info , which caused php-fpm responsed status 0 with not found html;
which caddy logs panic.

please check your path_info parse code .

We have a rule called split that acts similarly with the nginx fastcgi_split_path_info

https://caddyserver.com/docs/fastcgi --> split

have you tried to use it to see what happens?

@theodesp finally , I found the problem .

I use chrome replay xhr , and change the backend software,and dump the $_SERVER

nginx without fastcgi_split_path_info

array(40) {
  ["USER"]=>
  string(4) "root"
  ["HOME"]=>
  string(5) "/root"
  ["PATH_TRANSLATED"]=>
  string(5) "/data"
  ["ORIG_SCRIPT_FILENAME"]=>
  string(33) "/data/remote.php/webdav/index.php"
  ["HTTP_COOKIE"]=>
  string(281) "nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n"
  ["HTTP_ACCEPT_LANGUAGE"]=>
  string(23) "zh-CN,zh;q=0.9,en;q=0.8"
  ["HTTP_ACCEPT_ENCODING"]=>
  string(13) "gzip, deflate"
  ["HTTP_ACCEPT"]=>
  string(3) "*/*"
  ["HTTP_DEPTH"]=>
  string(1) "1"
  ["HTTP_USER_AGENT"]=>
  string(121) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36"
  ["HTTP_CONTENT_TYPE"]=>
  string(30) "application/xml; charset=UTF-8"
  ["HTTP_X_REQUESTED_WITH"]=>
  string(14) "XMLHttpRequest"
  ["HTTP_ORIGIN"]=>
  string(33) "http://xmpp.git.suconghou.cn:9098"
  ["HTTP_REQUESTTOKEN"]=>
  string(89) "9hrxk52bKl/v/8F/AhZ/xrD2YGu/3UuGcOd7ENuQS0Y=:g3CCwdHhGhXaq68oalVPs9OyV17LtH7UKaUeWY/4Mww="
  ["HTTP_CONTENT_LENGTH"]=>
  string(3) "493"
  ["HTTP_CONNECTION"]=>
  string(10) "keep-alive"
  ["HTTP_HOST"]=>
  string(26) "xmpp.git.suconghou.cn:9098"
  ["REDIRECT_STATUS"]=>
  string(3) "200"
  ["SERVER_NAME"]=>
  string(9) "localhost"
  ["SERVER_PORT"]=>
  string(4) "9098"
  ["SERVER_ADDR"]=>
  string(10) "172.17.0.2"
  ["REMOTE_PORT"]=>
  string(5) "37886"
  ["REMOTE_ADDR"]=>
  string(10) "172.17.0.1"
  ["SERVER_SOFTWARE"]=>
  string(12) "nginx/1.14.0"
  ["GATEWAY_INTERFACE"]=>
  string(7) "CGI/1.1"
  ["REQUEST_SCHEME"]=>
  string(4) "http"
  ["SERVER_PROTOCOL"]=>
  string(8) "HTTP/1.1"
  ["DOCUMENT_ROOT"]=>
  string(5) "/data"
  ["DOCUMENT_URI"]=>
  string(19) "/remote.php/webdav/"
  ["REQUEST_URI"]=>
  string(19) "/remote.php/webdav/"
  ["SCRIPT_NAME"]=>
  string(28) "/remote.php/webdav/index.php"
  ["CONTENT_LENGTH"]=>
  string(3) "493"
  ["CONTENT_TYPE"]=>
  string(30) "application/xml; charset=UTF-8"
  ["REQUEST_METHOD"]=>
  string(8) "PROPFIND"
  ["QUERY_STRING"]=>
  string(0) ""
  ["SCRIPT_FILENAME"]=>
  string(16) "/data/remote.php"
  ["FCGI_ROLE"]=>
  string(9) "RESPONDER"
  ["PHP_SELF"]=>
  string(28) "/remote.php/webdav/index.php"
  ["REQUEST_TIME_FLOAT"]=>
  float(1524222208.5185)
  ["REQUEST_TIME"]=>
  int(1524222208)
}

nginx with fastcgi_split_path_info

array(38) {
  ["USER"]=>
  string(4) "root"
  ["HOME"]=>
  string(5) "/root"
  ["HTTP_COOKIE"]=>
  string(281) "nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n"
  ["HTTP_ACCEPT_LANGUAGE"]=>
  string(23) "zh-CN,zh;q=0.9,en;q=0.8"
  ["HTTP_ACCEPT_ENCODING"]=>
  string(13) "gzip, deflate"
  ["HTTP_ACCEPT"]=>
  string(3) "*/*"
  ["HTTP_DEPTH"]=>
  string(1) "1"
  ["HTTP_USER_AGENT"]=>
  string(121) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36"
  ["HTTP_CONTENT_TYPE"]=>
  string(30) "application/xml; charset=UTF-8"
  ["HTTP_X_REQUESTED_WITH"]=>
  string(14) "XMLHttpRequest"
  ["HTTP_ORIGIN"]=>
  string(33) "http://xmpp.git.suconghou.cn:9098"
  ["HTTP_REQUESTTOKEN"]=>
  string(89) "9hrxk52bKl/v/8F/AhZ/xrD2YGu/3UuGcOd7ENuQS0Y=:g3CCwdHhGhXaq68oalVPs9OyV17LtH7UKaUeWY/4Mww="
  ["HTTP_CONTENT_LENGTH"]=>
  string(3) "493"
  ["HTTP_CONNECTION"]=>
  string(10) "keep-alive"
  ["HTTP_HOST"]=>
  string(26) "xmpp.git.suconghou.cn:9098"
  ["REDIRECT_STATUS"]=>
  string(3) "200"
  ["SERVER_NAME"]=>
  string(9) "localhost"
  ["SERVER_PORT"]=>
  string(4) "9098"
  ["SERVER_ADDR"]=>
  string(10) "172.17.0.2"
  ["REMOTE_PORT"]=>
  string(5) "37882"
  ["REMOTE_ADDR"]=>
  string(10) "172.17.0.1"
  ["SERVER_SOFTWARE"]=>
  string(12) "nginx/1.14.0"
  ["GATEWAY_INTERFACE"]=>
  string(7) "CGI/1.1"
  ["REQUEST_SCHEME"]=>
  string(4) "http"
  ["SERVER_PROTOCOL"]=>
  string(8) "HTTP/1.1"
  ["DOCUMENT_ROOT"]=>
  string(5) "/data"
  ["DOCUMENT_URI"]=>
  string(19) "/remote.php/webdav/"
  ["REQUEST_URI"]=>
  string(19) "/remote.php/webdav/"
  ["SCRIPT_NAME"]=>
  string(11) "/remote.php"
  ["CONTENT_LENGTH"]=>
  string(3) "493"
  ["CONTENT_TYPE"]=>
  string(30) "application/xml; charset=UTF-8"
  ["REQUEST_METHOD"]=>
  string(8) "PROPFIND"
  ["QUERY_STRING"]=>
  string(0) ""
  ["SCRIPT_FILENAME"]=>
  string(16) "/data/remote.php"
  ["FCGI_ROLE"]=>
  string(9) "RESPONDER"
  ["PHP_SELF"]=>
  string(11) "/remote.php"
  ["REQUEST_TIME_FLOAT"]=>
  float(1524222175.8476)
  ["REQUEST_TIME"]=>
  int(1524222175)
}

use vimdiff two file. the difference is PHP_SELF and SCRIPT_NAME

it shows that nginx with fastcgi_split_path_info got the right value

 ["PHP_SELF"]=>
  string(11) "/remote.php"
["SCRIPT_NAME"]=>
  string(11) "/remote.php"

the wrong value which nginx without fastcgi_split_path_info got

 ["PHP_SELF"]=>
  string(28) "/remote.php/webdav/index.php"
["SCRIPT_NAME"]=>
  string(28) "/remote.php/webdav/index.php"

use caddy with config

xmpp.git.suconghou.cn:9098
tls off
gzip
root /data/
fastcgi / 127.0.0.1:9000 php {
    split .php
}

it got

array(45) {
  ["USER"]=>
  string(4) "root"
  ["HOME"]=>
  string(5) "/root"
  ["ORIG_PATH_TRANSLATED"]=>
  string(12) "/data/webdav"
  ["ORIG_SCRIPT_FILENAME"]=>
  string(23) "/data/remote.php/webdav"
  ["ORIG_SCRIPT_NAME"]=>
  string(11) "/remote.php"
  ["ORIG_PATH_INFO"]=>
  string(8) "/webdav/"
  ["HTTP_CONTENT_TYPE"]=>
  string(30) "application/xml; charset=UTF-8"
  ["SERVER_NAME"]=>
  string(21) "xmpp.git.suconghou.cn"
  ["HTTP_DEPTH"]=>
  string(1) "1"
  ["SCRIPT_FILENAME"]=>
  string(16) "/data/remote.php"
  ["REMOTE_HOST"]=>
  string(10) "172.17.0.1"
  ["HTTP_CONNECTION"]=>
  string(10) "keep-alive"
  ["PATH_TRANSLATED"]=>
  string(12) "/datawebdav/"
  ["SERVER_SOFTWARE"]=>
  string(13) "Caddy/0.10.14"
  ["CONTENT_TYPE"]=>
  string(30) "application/xml; charset=UTF-8"
  ["CONTENT_LENGTH"]=>
  string(3) "493"
  ["HTTP_COOKIE"]=>
  string(281) "nc_sameSiteCookielax=true; nc_sameSiteCookiestrict=true; oc_sessionPassphrase=789fmGgf7LOAn2bKnwJJ9ocKbYVrX04XYgWjfYxm5lilRd8kgwXoeNIbKsTD20WFZCgSj2J6mvN%2BxGdDy5YWRgRzQJiZVO8Uciy2v9O86JyMi6DlIf1mLon2JXjvBS5c; _ga=GA1.2.191332580.1522131691; ocpfsn3rqwyq=4belbrmp3vjg1bi3bjobuicm8n"
  ["HTTP_ACCEPT"]=>
  string(3) "*/*"
  ["SERVER_PORT"]=>
  string(4) "9098"
  ["HTTP_USER_AGENT"]=>
  string(121) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36"
  ["HTTP_ORIGIN"]=>
  string(33) "http://xmpp.git.suconghou.cn:9098"
  ["HTTP_ACCEPT_LANGUAGE"]=>
  string(23) "zh-CN,zh;q=0.9,en;q=0.8"
  ["HTTP_CONTENT_LENGTH"]=>
  string(3) "493"
  ["DOCUMENT_ROOT"]=>
  string(5) "/data"
  ["REMOTE_USER"]=>
  string(0) ""
  ["QUERY_STRING"]=>
  string(0) ""
  ["HTTP_X_REQUESTED_WITH"]=>
  string(14) "XMLHttpRequest"
  ["PATH_INFO"]=>
  string(7) "webdav/"
  ["HTTP_REQUESTTOKEN"]=>
  string(89) "9hrxk52bKl/v/8F/AhZ/xrD2YGu/3UuGcOd7ENuQS0Y=:g3CCwdHhGhXaq68oalVPs9OyV17LtH7UKaUeWY/4Mww="
  ["HTTP_ACCEPT_ENCODING"]=>
  string(13) "gzip, deflate"
  ["HTTP_HOST"]=>
  string(26) "xmpp.git.suconghou.cn:9098"
  ["DOCUMENT_URI"]=>
  string(11) "/remote.php"
  ["REMOTE_ADDR"]=>
  string(10) "172.17.0.1"
  ["REMOTE_IDENT"]=>
  string(0) ""
  ["SCRIPT_NAME"]=>
  string(1) "/"
  ["REQUEST_URI"]=>
  string(19) "/remote.php/webdav/"
  ["SERVER_PROTOCOL"]=>
  string(8) "HTTP/1.1"
  ["REQUEST_METHOD"]=>
  string(8) "PROPFIND"
  ["REMOTE_PORT"]=>
  string(5) "37900"
  ["GATEWAY_INTERFACE"]=>
  string(7) "CGI/1.1"
  ["AUTH_TYPE"]=>
  string(0) ""
  ["FCGI_ROLE"]=>
  string(9) "RESPONDER"
  ["PHP_SELF"]=>
  string(8) "/webdav/"
  ["REQUEST_TIME_FLOAT"]=>
  float(1524222536.0769)
  ["REQUEST_TIME"]=>
  int(1524222536)
}

notice the output

["PHP_SELF"]=>
  string(8) "/webdav/"
["SCRIPT_NAME"]=>
  string(1) "/"

and

["PATH_TRANSLATED"]=>
  string(12) "/datawebdav/"

all is wrong . I never have a dir called /datawebdav/ .

to get a conclusion

I use caddy and modify the remote.php on the first line, give $_SERVER["PHP_SELF"] or $_SERVER["SCRIPT_NAME"] the right value;

finally, it shows SCRIPT_NAME=/ caused php-fpm responsed status 0 .
and I give it a right value $_SERVER['SCRIPT_NAME']='/remote.php' on the first line, everything goes well.

It proved that caddy's fastcgi module is defective.

by the way . I test it with Caddy 0.10.14 (unofficial) now.

/datawebdav/ is because this happens:

https://github.com/mholt/caddy/blob/ca34a3e1aa21c767322f9275c2281df96a3eb402/caddyhttp/fastcgi/fastcgi.go#L323

root is /data and pathInfo is webdav/ the they join into /datawebdav/

Now the pathinfo is assigned here:
https://github.com/mholt/caddy/blob/ca34a3e1aa21c767322f9275c2281df96a3eb402/caddyhttp/fastcgi/fastcgi.go#L267

Mybe there is an overlap when we splitting the strings to paths so the env gets populated wrong, I'm not sure.

For this request to /remote.php/webdav/ the values should be:

script_name = /remote.php
path_info= /webdav/

@theodesp it is clear, have you solved this bug ?

@suconghou can you verify with that merge fix #2158 that the issue still holds or not?

@theodesp I use the master branch and build from source , it works well, no error, everything is ok ; but the variable PHP_SELF became /remote.php/webdav/ , does it right ?

Original issue was fixed in #2158.

Could this issue be closed?

Was this page helpful?
0 / 5 - 0 ratings