gpt4 book ai didi

angular - 将 angular-universal 部署到 apache 服务器(Angular 9)

转载 作者:行者123 更新时间:2023-12-04 18:39:34 24 4
gpt4 key购买 nike

在本地构建并运行 Angular Universal 之后,我正在尝试部署到 apache 服务器。我正在将 dist 文件夹移动到公共(public) html。

enter image description here

我跑node dist/server/main.js它从端口 localhost:4000 开始,当我 curl localhost:4000 时,我正在获取内容。

p.s. I have also install pm2, and when I try pm2 start dist/server/main.js starts the server but when I try to curl it shows Internal server error



我还编辑了 .conf 文件以代理到 localhost:4000:
ProxyPreserveHost On
ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/

当我尝试访问它时显示

enter image description here

虚拟主机文件

    DocumentRoot /var/www/domain/public/dist/browser

<Directory /var/www/domain>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>

RewriteEngine on
RewriteCond %{SERVER_NAME} =domain [OR]
RewriteCond %{SERVER_NAME} =domain
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

ProxyPreserveHost On

ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/

最佳答案

由于我使用的是 Let's Encrypt CA,它会在 /etc/apache2/sites-available 中创建其 .conf 文件。

yourdomain-le-ssl.conf



所以从 yourdomain.conf 代理到 localhost:4000文件配置不正确,从 yourdomain-le-ssl.conf 代理是正确的

关于angular - 将 angular-universal 部署到 apache 服务器(Angular 9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61776213/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com