nginx rewrite 出现 403 forbidden

各位好
小弟有几台服务器,其中一台有公网IP(gateway)和另外几台内网机器,内网在同一网段。其中一台内网机器安装php运行phpMyAdmin,并且使用nginx作为web服务,配置为

server {
    listen 80;
    root /home/xxx/www; #phpMyAdmin放在这个目录下
    index index.html index.htm index.php;

    server_name 10.xxx.xxx.xxx  www.xxx.com;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        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;
    }
}

网关服务器上的nginx配置为

server {
    listen        80;

    server_name www.xxx.com;

    location / {
        index index.php index.html;
        rewrite /(.*) /$1 break;
        proxy_pass http://10.xxx.xxx.xxx/phpMyAdmin/;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    #location / {
    #    index index.php index.html;
    #    proxy_pass http://10.xxx.xxx.xxx/phpMyAdmin/;
    #}
}

现在如果直接访问http://www.xxx.com,则报403 forbidden。

但如果直接把外网IP绑定到php那台内网机器再访问http://www.xxx.com/phpMyAdmin...

请问各位大神,从网关rewrite到内网机器的配置是哪里有问题吗?

阅读 2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题