[英]Reverse proxy Angular Application using Apache Http
I'm building Angular Application.我正在构建 Angular 应用程序。 I need to reverse proxying this application using Apache Http:
我需要使用 Apache Http 反向代理此应用程序:
http://localhost:4200 to http://localhost/my-application http://localhost:4200 到 http://localhost/my-application
I followed the following steps:我按照以下步骤操作:
ProxyPass /my-application http://127.0.0.1:4200/
ProxyPassReverse /my-application http://127.0.0.1:4200/
Unfortunately, I have the following problem:不幸的是,我有以下问题:
GET http://localhost/runtime.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost/polyfills.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost/vendor.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost/main.js net::ERR_ABORTED 404 (Not Found)
GET http://localhost/styles.css net::ERR_ABORTED 404 (Not Found)
GET http://localhost/styles.js net::ERR_ABORTED 404 (Not Found)
I also added the following configuration, into the httpd configuration file:我还在 httpd 配置文件中添加了以下配置:
ProxyPass /my-application/runtime.js http://127.0.0.1:4200/my-application/runtime.js
ProxyPassReverse /my-application/runtime.js http://127.0.0.1:4200/my-application/runtime.js
I didn't solve the problem.我没有解决问题。
This issue seems not be a problem of Apache or reverse proxy, but more likely the references that angular uses to get the files from index.html这个问题似乎不是 Apache 或反向代理的问题,但更有可能是 angular 用于从 index.html 获取文件的引用
In your example you need to retrive files from./my-application and not from the root page of localhost "GET http://localhost/runtime.js"在您的示例中,您需要从 ./my-application 而不是从 localhost "GET http://localhost/runtime.js" 的根页面检索文件
Try to change your base尝试改变你的基地
<base href="/my-application">
For more information follow https://angular.io/guide/deployment有关更多信息,请关注https://angular.io/guide/deployment
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.