小编Ser*_*vin的帖子

Symfony 和 nginx - 调用 API 时出现 502 Bad Gateway 错误

我使用 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)

php authentication nginx symfony

4
推荐指数
1
解决办法
4776
查看次数

标签 统计

authentication ×1

nginx ×1

php ×1

symfony ×1