PhpMyAdmin 使用反向代理在 Nginx 中显示错误

PhpMyAdmin wrong display in Nginx using reverse proxy

server {
    listen 80;
    listen [::]:80;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name localhost mywebsite.com www.mywebsite.com;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    location /phpmyadmin {
        root /var/www/html/phpmyadmin/;
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; 
    }
}

我设法让所有的工作都如我所愿,但是 PhpMyAdmin 的显示有问题:

在该文件中设置反向代理之前,PhpMyAdmin 运行 完美。我假设我在 default 文件中遗漏了一些东西。
有什么想法吗?谢谢


致 Ivan Shatsky 的回复: @IvanShatsky

我尝试用您的代码替换,但它下载了一个文件(它不读取 .php 文件)- 所以,我又添加了几行:

location ^~ /phpmyadmin {
    index index.php;
    try_files $uri $uri/ /phpmyadmin/index.php$is_args$args;
    
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

结果和之前一样
当我检查网络资源时,会发生以下情况:

我已经执行 chmod 777 -R /var/www/html/phpmyadmin 但没有更改。我需要有 https 吗? - 我目前正在尝试 http.

我想知道它是怎样的运行。假设您的 phpMyAdmin 位于 /var/www/html/phpmyadmin 目录中,试试这个:

location /phpmyadmin {
    index index.php;
    try_files $uri $uri/ /phpmyadmin/index.php$is_args$args;
}