From 008415f206dec7c72c3b0abe36d5a40213abb7a2 Mon Sep 17 00:00:00 2001
From: MisterDuval <devil1591@yahoo.fr>
Date: Sat, 14 Dec 2019 19:21:27 +0100
Subject: [PATCH] fastcgi: Trim dot and space suffix for Windows sake (#2917)

---
 caddyhttp/fastcgi/fastcgi.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/caddyhttp/fastcgi/fastcgi.go b/caddyhttp/fastcgi/fastcgi.go
index aab0ecdd2..9b17c88cf 100644
--- a/caddyhttp/fastcgi/fastcgi.go
+++ b/caddyhttp/fastcgi/fastcgi.go
@@ -85,6 +85,8 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
 		// but we also want to be flexible for the script we proxy to.
 
 		fpath := r.URL.Path
+		// We trim those characters because they are served as plain text if appended after .php on Windows 
+		fpath = strings.TrimRight(fpath, " .")
 
 		if idx, ok := httpserver.IndexFile(h.FileSys, fpath, rule.IndexFiles); ok {
 			fpath = idx