Caddyserver Dev Setup

I’ve been looking to replace WAMPServer as my development environment, as it is quite poor at serving assets correctly. In this endeavor Caddyserver seems optimal: HTTP/2, extremely lightweight, simple to set up with PHP, automatic HTTPS, simple virtual hosts, etc.

Setting Caddy up for Grav’s requirements were fairly straightforward, the problem is rather with the Caddyfile - ie. the server config - to correctly serve the files. I based my config on the repo one, though it needed a few tweaks to run on Windows.

I currently have two virtual hosts: Localhost and grav.dev, of which the former just runs phpinfo() and the latter Grav 1.1-RC2. However, Caddy returns “No input file specified.” when visiting grav.dev, and I’m not quite sure why.

Here’s the Caddyfile, with tweaks added from 404 with Caddy server:

localhost:80 {
	log logs/access.log
	errors logs/error.log
	gzip
	star tup php-cgi -b 127.0.0.1:9000 &
	fastcgi / 127.0.0.1:9000 php {
		index index.php
	}
}

# Grav
grav.dev:80 {
	root /grav
	log logs/access.log
	errors logs/error.log
	gzip
	startup php-cgi -b 127.0.0.1:9000 &
	fastcgi / 127.0.0.1:9000 {
		ext .php
		split .php
		index index.php
	}
	rewrite {
		regexp .*
		ext /
		to /index.php?_url={uri}
	}
	
	# Begin - Security
	# deny all direct access for these folders
	rewrite {
		r       /(.git|cache|bin|logs|backups|tests)/.*$
		status  403
	}
	# deny running scripts inside core system folders
	rewrite {
		r       /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$
		status  403
	}
	# deny running scripts inside user folder
	rewrite {
		r       /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$
		status  403
	}
	# deny access to specific files in the root folder
	rewrite {
		r       /(LICENSE.txt|composer.lock|composer.json|nginx.conf|web.config|htacce ss.txt|\.htaccess)
		status  403
	}
	## End - Security

	# global rewrite should come last.
	rewrite {
		to  {path} {path}/ /index.php?_url={uri}
	}
}

Any thoughts on what might be wrong?

I have a setup similar to yours, but not identical. Not having such error ( on a Mac), you might want to try it:


grav.develop:80 {
    errors /Users/flavio/www/error.log
    root /Users/flavio/www/grav-develop
    log /Users/flavio/www/caddy_access.log
    gzip
    fastcgi / 127.0.0.1:9000 php

    # Begin - Security
    # deny all direct access for these folders
    rewrite {
        r       /(.git|cache|bin|logs|backups|tests)/.*$
        status  403
    }
    # deny running scripts inside core system folders
    rewrite {
        r       /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ 
        status  403
    }
    # deny running scripts inside user folder
    rewrite {
        r       /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$
        status  403
    }
    # deny access to specific files in the root folder
    rewrite {
        r       /(LICENSE.txt|composer.lock|composer.json|nginx.conf|web.config|htacce ss.txt|\.htaccess)
        status  403
    }
    ## End - Security

    # global rewrite should come last.
    rewrite {
        to  {path} {path}/ /index.php?_url={uri}
    }
}

The problem was with root /grav, whereas Windows it expected root C:\caddy\grav. I assumed that it would be relative to Caddyserver’s root, not an absolute path.