我一直遇到有关在Apache上部署Angular ssr的问题。
我认为,需要在apache上配置.htaccess文件。 以下是我已经浏览过的一些链接,但是要么无法配置,要么描述不够彻底。
https://github.com/angular/universal-starter/issues/514
Angular2 Universal deploy to apache remote server
How to properly launch Angular Universal to live server
How to deploy Angular Universal project to standard hosting?
我的问题是在端口配置为8080的Apache服务器上的``custom''目录中部署Angular Universal-x.x.x.x:8080 / custom
采取的步骤
1)将dist / *部署到/ var / www / html / custom
2)npm install安装deps
3)pm2在dist文件夹下启动server.js
导航到x.x.x.x:8080 / custom会给出目录结构。
我认为我需要将请求重定向到以PM2启动的应用程序正在侦听的端口。
我应该怎么做
不胜感激!!
答案 0 :(得分:1)
我们正在使用pm2 ecosystem指向本地主机
首先在httpd.conf中启用mod_proxy和mod_proxy_http!
如果您使用的是虚拟主机,则将以下代理设置添加到特定于域的主机文件中-
ProxyPreserveHost On
ProxyPass / http://localhost:4200/
ProxyPassReverse / http://localhost:4200/
重新启动Apache和pm2
因此,如果您访问实时域名,例如www.example.com将由pm2通过localhost:4200投放
答案 1 :(得分:0)
您可以将apache服务器与pm2服务器映射:
默认配置文件:/etc/httpd/conf/httpd.conf
ProxyPass /example http://xx.xx.xx.xx:xx/
ProxyPassReverse /example http://xx.xx.xx.xx:xx/
这会将所有请求从apache服务器路由到您的pm2服务器