Issues with PHP overrriding file browse directive

1. Caddy version (caddy version):

docker

2. How I run Caddy:

docker

http://486net.tk, http://www.486net.tk { #, http://192.168.0.101 {
		root * /home/486net/www
		templates
		php_fastcgi unix//run/php-fpm/php-fpm.sock
		file_server / {
			hide   .git .gitignore .gitmodules
			index  index.htm index.html index.md
			browse /home/486net/www/assets/file-template.htm
		}

		try_files {path} {path}/index.html index.html index.htm
}

this is index.php
https://hastebin.com/uzosobebeh.php-template

3. The problem Iā€™m having:

When i go to a page such as http://486net.tk/FolderTest/ it only displays what i would see if i was on http://486net.tk/

What i am supposed to be seeing

What i am NOT supposed to see

the only difference between these two screenshots, is in the first one, php_fastcgi is disabled (commented)
and in the second one, it is enabled (uncommented)

4. Error messages and/or full log output:

LItterally nothing

5. What I already tried:

I have tried a try_files to directly show index.htm, index.html, and even index.txt and nothing has worked,

6. Links to relevant resources:

Somewhat fixed by adding a request matcher like so

@phpcheck path *.php
php_fastcgi @phpcheck unix//run/php-fpm/php-fpm.sock

HOWEVER, index.php files do not work, and display plaintext of the php file

The problem is you set a / matcher for your file_server directive, making it only match for requests to exactly /.

1 Like

Newly updated caddyfile after tweaking it till something worked

http://486net.tk, http://www.486net.tk { #, http://192.168.0.101 {
		root * /home/486net/www
		templates
		@phpcheck path *.php
		php_fastcgi @phpcheck unix//run/php-fpm/php-fpm.sock
		file_server * {
			root /home/486net/www
			hide   .git .gitignore .gitmodules
			index  index.htm index.html index.md index.php
			browse /home/486net/www/assets/file-template.htm
		}
		rewrite / /index.php ## How i have the main index.php working at the moment
}

I doubt you need that @phpcheck matcher.

1 Like

I think all you need is this:

http://486net.tk, http://www.486net.tk {
		root * /home/486net/www
		templates
		php_fastcgi unix//run/php-fpm/php-fpm.sock
		file_server {
			hide   .git .gitignore .gitmodules
			index  index.htm index.html index.md index.php
			browse /home/486net/www/assets/file-template.htm
		}
}

This topic was automatically closed after 30 days. New replies are no longer allowed.