nginx - Nginx 保留代理导航回主机
问题描述
我设置了2页如下:
- 当前主机的旧项目
- 新主机上的 reactjs 和 nextjs 的新项目
我想使用 nginx 从我的旧页面到新项目的下游
http://current-host/my-new-proj
至
http://new-host/my-new-proj
我尝试在当前主机上设置这样的 nginx 配置
server {
listen 80;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /my-new-project {
proxy_pass http://new-host/my-new-project;
}
location ^~ /_next/ {
proxy_pass http://new-host/_next/;
}
}
它似乎工作正常,但在新页面中我有一个链接可以导航到旧主页
<a href="http://current-host/"/>
但是,单击时不是导航到主页,而是导航到新项目的主页,当我刷新浏览器时,页面然后重新加载并显示正确的主页
我假设 nginx 正在检测请求的主机与当前主机相同,那么它只会触发应用内处理而不是导航。
无论如何我可以将此链接重定向到旧主机吗?
解决方案
推荐阅读
- rest - 使用 HMAC 时随机数 RESTful 是如何实现的?
- r - R purr:将精度映射到预测对象并返回精度
- php - Xdebug 无法使用 XAMPP 开发服务器连接到 Windows 10 上的 VS Code
- google-apps-marketplace - 管理员中的代码 API 默认签名 gsuite 电子邮件
- python - 使用 FuncAnimation 动态更新 3d 散点图/点图中的 ax.text 位置
- powershell - 如何在Powershell中的文件中的每一行上打印/附加行索引号
- dc.js - Sharepoint 错误上的 aspx 页面:仅在呈现数据表时需要功能
- android - 如何在android studio中动态更改src属性?
- apache - httpd 服务正在启动,尽管它在重新启动时无法启动
- php - php 检查字符串的特定格式