如何设置 nginx.conf 中的位置以删除 URL 的尾部斜线?

how to set the locaction in nginx.conf for removing URL's trailing slash?

今天用了两台服务器nginx,nginx.conf的内容如下:

#192.168.2.98
server {
    listen 8091;
    location ^~ /ttank {
        alias /develop/servers-running/front/vue-public/dist;
        index index.html;
        try_files $uri $uri/ /ttank/index.html;
     }
 }



#192.168.2.97
location /ttank {
   proxy_pass http://192.168.2.98:8091;
   proxy_set_header Host $host;
   proxy_set_header  X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_redirect off;
}

我可以通过输入地址访问192.168.2.98:8091/ttankhttp://192.168.2.98:8091/ttank in chrome, I also can access 192.168.2.98's ttank by entering the address http://192.168.2.97/ttank/, but when I change the addres http://192.168.2.97/ttank/ into http://192.168.2.97/ttank,我的chrome永远进入等待状态,两个地址唯一的区别就是最后一个“/”,访问ttank[=22时不知道如何修改配置文件去掉最后一个“/” =] 来自 192.168.2.97

尝试使用重写规则去掉结尾的斜杠

location /ttank {
    rewrite ^/(.*)/$ / break;
    ...;
    ...;
    proxy_pass ...;
}

应该这样做