https://www.workerman.net/doc/webman/others/nginx-proxy.html
按照webman这里进行部署访问前台是没有问题的,但是访问admin就会出现静态资源404的问题。
/app/admin/component/pear/css/pear.css net::ERR_ABORTED 404 (Not Found)
/app/admin/component/layui/layui.js?v=2.8.12 net::ERR_ABORTED 404 (Not Found)
使用下面的配置访问都正常,但是会暴露项目的文件,项目几乎所有文件都能被下载。
location ^~ / {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
proxy_set_header Connection "";
if (!-f $request_filename){
proxy_pass http://webman;
}
}
按照webman系统能够自动把admin插件的静态资源代理过去的呀,插件里配置了public_path的。
return [
'debug' => true,
'controller_suffix' => 'Controller',
'controller_reuse' => false,
'public_path' => base_path('plugin' . DIRECTORY_SEPARATOR. 'admin' . DIRECTORY_SEPARATOR . 'public'),
'plugin_market_host' => 'https://www.workerman.net',
'version' => '0.6.33',
];
请问要如何正确的配置呢?
设置了运行目录为public之后,也就public目录下面的文件可以访问,包括admin/public目录
其它文件是没法访问的,如果可以,那得检查一下nginx的配置
你说的暴露项目的文件是暴露了哪些文件?
我也很奇怪这点,配置是宝塔默认的项目配置,加了webman的代理。
使用location ^~ / 这种方式代理就会导致项目目录的文件能被下载,比如.env,start.php等。非常不安全,所以才来问呀。
https://www.workerman.net/doc/webman/others/nginx-proxy.html
按照文档
上面这些配置决定了访问 .php 文件和访问 .env 文件都会404。
如果你能访问到,说明你没加这些配置。
文档强调 root配置到 public 目录,public下不会有 start.php 和 .env ,如果你能访问到,说明这里也没配置对。
大家都没问题,你有问题,所以应该是你没按照文档配置导致的。
我现在的解决方案其实也差不多吧
手动配置哪些不能访问。