Deploying Angular Universal in Apache

I have been encountering problem regarding deployment of Angular ssr on Apache.

I believe, configuration on apache is needed alongwith .htaccess file. Below are some links which I have been through, but either I was not able to configure or the description was not thorough enough to implement.

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?

My issue is deploying Angular Universal on Apache server with port configured to 8080 and inside a directory 'custom' -- x.x.x.x:8080/custom

Steps Taken

1) Deployed dist/* to /var/www/html/custom

2) npm install to install deps

3) pm2 to start server.js under dist folder

Screen shot attached-- enter image description here

enter image description here

enter image description here

Navigating to x.x.x.x:8080/custom gives the directory structure instead.

I think I need to redirect requests to the port that the app started with PM2 is listening on.

How shall that be done is my concern

Help much appreciated !!

1 answer

  • answered 2019-05-15 06:18 GoutamS

    You can map apache server with pm2 server:

    Default Config File: /etc/httpd/conf/httpd.conf

    ProxyPass         /example  http://xx.xx.xx.xx:xx/
    ProxyPassReverse  /example  http://xx.xx.xx.xx:xx/
    

    This will route all request from apache server to your pm2 server