【发布时间】:2020-03-30 12:27:57
【问题描述】:
这是我第一次为 symfony 项目配置 nginx(使用 docker)。
到我的索引文件的路径一切正常。 但是现在我需要使用到 public/styles/*****.css 和其他类似 public/js 等的路由。
我无法运行它。它总是告诉我 symfony 不允许路由,或者不允许来自 nginx 的其他尝试,HTML500。
这是我的 NGINX 配置:
server {
server_name ~.*;
location / {
root /usr/src/app;
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
client_max_body_size 50m;
fastcgi_pass php:9000;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/src/app/symfony/public/index.php;
}
error_log /dev/stderr debug;
access_log /dev/stdout;
}
这是我尝试调用的:
http://localhost:8000/styles/main.css
http://localhost:8000 -> works proper, loading my index route
这是我的 base.html.twig 的一部分
<link href="styles/main.css" rel="stylesheet" type="text/css">
【问题讨论】:
-
你是否在同一个 docker 镜像中运行 Nginx 和 Symfony?
-
不,nginx 和 php 在不同的容器中运行