如何从nginx站点的URL中删除端口号



在一个URL中,我看到的内容类似于:http://example.com:8000/page。尽管我可以通过在没有端口的情况下键入URL来访问网站,但当我转到任何子页面时,它都会添加到那里。

我曾经有一个基于Python的web服务器,而不是nginx,它运行得很好,然而,端口号从来没有出现过。这就是为什么我仍然希望有一种方法可以隐藏非标准端口(而不将其更改为标准端口(,因为Python web服务器没有显示。

顺便说一下,我重定向端口80>>8000。

nginx配置中是否有向站点隐藏非标准端口的功能?如果没有,也许还有其他方法?

我的配置:

server {
listen 8000;
access_log /logs/access.log;
error_log /logs/error.log;
index index.html;
server_name example.com;
error_page 404 errors/404.html; 
location / {
try_files $uri $uri/ =404;
}
}

我刚刚发现

port_in_redirect off;

最新更新