我使用 docker (php7.4 和 nginx)来运行我的 Symfony 5 应用程序,我使用 实现了 Bearer 身份验证firebase/php-jwt,并且可以成功获取令牌,但是当我尝试使用标头中的令牌调用 API 时,我得到了502 Bad Gateway(参见来自 nginx 的错误)。
我确信问题来自我的 nginx 配置,因为当我使用 Symfony 本地 Web 服务器时,它可以工作。
nginx 配置:
server {
listen 80;
server_name my.local;
root /home/my/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass my-app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}
location ~ \.php$ {
return 404;
}
error_log …Run Code Online (Sandbox Code Playgroud)