问题情况:

nginx监听的端口例如是8080,外网开放的端口为80,将80端口NAT到内部的8080端口,这时使用外网地址:http://tisunion.com/test访问时如果不在域名后面加/,那么域名地址会自动变为http://tisunion.com:8080/test/。

解决方法:

这是因为nginx做了端口重定向,只需要在nginx.conf配置文件的http或server中添加:port_in_redirect off;


Port_in_redirect

语法:port_in_redirect [on | off] 

默认值:port_in_redirect on 

Context:http,server,location 

作用:允许或阻止nginx处理在重定向的端口暗示。

在http里插入下面一行 

http {
    ...
    port_in_redirect off;
    ...
      }

目录不加“/”

在server节点内插入以下代码

server {
    ...
    location / {
        ...
        if (-d $request_filename){
            rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
        }
    }
    ...
}

PHPmyAdmin登录

在 config.inc.php 加入以下配置

$cfg['PmaAbsoluteUri'] = 'http:///path/to/phpmyadmin/';