我按照 Digital Ocean 的教程设置了 Nginx、PHP 和 phpmyadmin。
但是我仍然无法使用我设置的地址(my-ip-address/phpmyadmin)访问phpmyadmin。
我为在 localhost:8010 上监听的 Node.js 应用程序设置了反向代理。
这是/etc/nginx/sites-available/default 文件中的设置:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name "my ip address";
location / {
proxy_pass http://localhost:8010/;
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 ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
最佳答案
您正在将所有请求代理到 http://localhost:8010有了这个 block :
location / {
proxy_pass http://localhost:8010/;
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;
}
所有请求都无法发送至 phpmyadmin。尝试注释掉此 block 或删除它,它应该按您的预期工作。
关于nginx - 在 Ubuntu 16.04 上的 Nginx 中设置 phpmyadmin 和反向代理后无法 GET/phpmyadmin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51883851/