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

时间:2020-05-13 13:40:20

标签: angular apache ubuntu angular-universal

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

enter image description here

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

p.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/

1 个答案:

答案 0 :(得分:0)

由于我使用的是Let's Encrypt CA,因此它将在/etc/apache2/sites-available

中创建其.conf文件。

yourdomain-le-ssl.conf

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