linux - 如何从 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;
解决它。
推荐阅读
- javascript - 在获得角度 5 的结果后,如何确保 typescript 接口属性为大写?
- tensorflow - 有什么方法可以创建点对点 TensorFlow 环境?
- post - 没有 FormUrlEncodedContent 的 HttpClient Post
- java - 如何在java线程中实现检查连接是否存在?
- java - 使用 Firebase for android 发送电子邮件验证时未选中的分配警告
- java - Spring 数据存储库不检查标记为在主实体下级联的类上的 isNew(entity)
- java - 片段中 RecyclerView 中的 textView 不显示来自 Java 或 XML 文件的任何文本
- r - sparklyr 中 R 的 list() 函数的等价物是什么?
- laravel - Laravel:关系内的搜索查询
- mongodb - 使用 NoSQL Manager for MongoDB 工具的错误