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

标签 angular apache ubuntu angular-universal

在本地构建并运行 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/

相关文章:

ubuntu - 安装 Racket 的问题

ubuntu - 权限被拒绝 : u'/opt/cloudera/parcel-cache/CDH-5. 3.3-1.cdh5.3.3.p0.5-precise.parcel.part'

angular - 如果条件匹配,如何在 Angular 2 中设置 ngStyle

html - 如何在Angular 7/Typescript中将HTML分配给字符串变量时按类名解析内部HTML

javascript - 如何使用纯 JavaScript 在 Angular2 中使用 RouteConfig?

javascript - angular2同一路由器导出的多级子路由

java - Apache FTP 服务器 : MVN Build Failed on Java 8 (SSL)

linux - 需要服务器监控/警报应用程序

java - apache poi如何刷新整个工作簿

ubuntu - 无法在 Ubuntu VM 上安装陨石