【发布时间】:2020-10-23 13:19:59
【问题描述】:
- 我在 Nginx 中运行一个 NodeJS 应用程序,反向代理到端口 3000
- PhpMyAdmin 已配置,显然在 /phpmyadmin 中运行
- /etc/nginx/sites-available/default 配置如下:
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。
【问题讨论】:
标签: nginx phpmyadmin reverse-proxy