nginx - Nginx proxy_pass 规则不适用于我的角度应用程序
问题描述
以下是在我的 Nginx 服务器中创建的用于指向两个应用程序的 proxy_pass 规则。代理规则适用于默认 URL,但我无法指出在端口 2000 中运行的应用程序。请帮助我找到根本原因。这是由于 URL 中的 # 造成的吗?
server {
listen 80 default_server;
listen [::]:80 default_server;
location /#/login {
proxy_pass http://3.81.197.217:2000;
}
location / {
proxy_pass http://3.81.197.217;
}
}
更多细节
- http://3.81.197.217:2000是一个运行在 2000 端口的 Angular 应用程序
- http://3.81.197.217是在同一个盒子的 80 端口上运行的另一个应用程序。
这两个应用程序都是用 Angular 构建的,并且在 URL 中有 #
解决方案
我认为最好的方法是使用不同的子域,因为这两个应用程序都有很多路由,所以你的解决方案会产生很多冲突。
中的问题/
。试试这个配置它会工作。
server {
listen 80 default_server;
listen [::]:80 default_server;
location /#/login/ {
proxy_pass http://3.81.197.217:2000/;
}
location / {
proxy_pass http://3.81.197.217/;
}
}
推荐阅读
- java - 将偏移量和eof文件查找到另一个文件中
- reactjs - React Native 如何通过更改语言来更改整个应用程序文本?
- javascript - 如何提醒没有 id 的单击 div 的内部 html?
- alfresco - 如何在数据库中查询alfresco的元数据与内容的关系
- html - 在此上下文中不允许使用自动填充字段名称“邮政编码”
- ruby-on-rails - 从 4.2 升级后与 Rails 5.0.6 捆绑时出现捆绑器错误
- mysql - Mariadb:赋值运算符 (:=) 不适用于局部变量
- r - 在同一轴上绘制两条线,而不会导致 y 轴上的值重叠
- node.js - Stripe 将 paymentMethod 添加到试用订阅并稍后验证信用卡
- java - 将 HATEOAS 对象作为 websocket 消息广播,其 Content-Type 不是 application/json