Nginx 导致 Adminer SQL Web 管理员访问出现问题

问题描述 投票:0回答:1

我是 nginx 新手。
我有一个 php 服务器在 127.0.0.1:82 上侦听(从 adminer firectory 启动,因此在请求时它会提供 adminer.php),并且在 127.0.0.1:80 上侦听 nginx。 我需要将任何 /admin 请求重定向到管理员,即 PHP 服务器。当我尝试 localhost:82/aminer.php 时,它工作得很好。但是当我通过 nginx (localhost:80/admin/aminer.php) 尝试它时,只有起始页面有效。当我尝试授权时,收到的 HTTP 响应包含代码 403(访问被拒绝)。如果我输入错误的密码,GUI 不会显示“用户‘管理员’登录失败”之类的错误,它只会重置页面。 enter image description here

我无法弄清楚问题所在。
这是我的 nginx 配置文件:

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http
{
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    
    #include /etc/nginx/conf.d/*.conf;
    #include /etc/nginx/sites-enabled/*;    
    
    server
    {
        listen localhost:80;
        
        location /admin/
        {
            proxy_pass http://localhost:82/;
            proxy_no_cache 1;
        }
    }
    

    ##
    # Basic Settings
    ##

    #sendfile on;
    #tcp_nopush on;
    #tcp_nodelay on;
    #keepalive_timeout 65;
    #types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    #include /etc/nginx/mime.types;
    #default_type application/octet-stream;

    ##
    # SSL Settings
    ##

    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    #ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    ##
    # Gzip Settings
    ##

    gzip on;

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##
}

这就是我提升 PHP 服务器的方式:
enter image description here

Ypu可以在这里看到adminer直接在:82端口上工作:
enter image description here

日志截图:
访问日志:
enter image description here

错误日志:
enter image description here

php 服务器日志:
enter image description here

nginx web-development-server adminer
1个回答
1
投票

Russian stackoverflow 上得到答案:

出现问题的原因是第一个

localhost/admin/
调用将请求重定向到
localhost:28/adminer.php
,但该页面上的任何请求或操作都将重定向到无效的
localhost:28/admin/adminer.php

要解决此问题,PHP 服务器必须启动上面的一个目录(以便

localhost:28/admin/adminer.php
可以重新调用文件 adminer.php。
另外,nginx 配置文件中的
proxy_pass http://localhost:82/;
行必须替换为
proxy_pass http://localhost:82;

© www.soinside.com 2019 - 2024. All rights reserved.