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

问题描述 投票:0回答:1

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

enter image description here

我运行node dist/server/main.js,它在端口localhost:4000上启动,当我卷曲localhost:4000时,我正在获取内容。

ps.s。我还安装了pm2,当我尝试pm2 start dist/server/main.js启动服务器时,但是当我尝试卷曲时,它显示内部服务器错误

我也编辑了.conf文件以代理到localhost:4000:

ProxyPreserveHost On
ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/

当我尝试访问它时显示

enter image description here

vhost文件

    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/

angular apache ubuntu angular-universal
1个回答
0
投票

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

yourdomain-le-ssl.conf

因此从yourdomain.conf文件代理到localhost:4000的配置不正确,从yourdomain-le-ssl.conf代理的访问是正确的

© www.soinside.com 2019 - 2024. All rights reserved.