我有一个基于插件的服务器安装程序,运行PHP、Postgres和Caddy作为fpm服务器/反向代理,使用自动SSL为php5-fpm提供PHP应用程序(Framework 3/Sylius1.5)。
到目前为止,它运行得很好,但是没有使用任何静态文件,如CSS、图片、JS等等,尽管放置了file_server指令。任何静态内容都会得到404。
我的应用程序被复制到文件夹/srv/app中,其中/srv/app/public包含index.php,/srv/app/public/assets包含静态文件(包括几个子文件夹)。
这是我的卡迪文件:
{$SERVER_NAME}
log
route {
root * /srv/app/public
php_fastcgi unix//var/run/php/php-fpm.sock
encode zstd gzip
file_server
}我试图为file_server指令指定文件夹,如:
file_server assets/
或
file_server assets {
}每个都在route-branch中。
但这样,卡迪就什么都不干了,给了500英镑。
我怎么才能解决这个问题?
发布于 2022-10-03 11:51:06
对我来说,像这样的事情起作用了(为什么会这样,我不知道)。
目录是:
/projects/site
-- static
----- jquery
--------- jquery.js
index.php可以访问的站点为:http://1.2.3.4:8000/site
静态文件请求在例如:http://1.2.3.4:8000/site/static/jquery/jquery.js下面
:8000 {
root * /projects/site
@path {
not path /site/static*
path /site*
}
log {
output file /var/log/caddy/site.log
}
handle_path /site/static* {
root * /projects/site/static
file_server
}
php_fastcgi @path unix//run/php/php5.6-fpm.sock
}https://stackoverflow.com/questions/68060830
复制相似问题