skip to Main Content

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 !!

2

Answers


  1. 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

    Login or Signup to reply.
  2. We are using pm2 ecosystem to point localhost

    First enable mod_proxy and mod_proxy_http in httpd.conf!

    If you are using virtual host add the following proxy setting to your domain-specific host file-

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

    Restart your Apache and pm2

    So if you accessing your live domain e.g http://www.example.com will serve by pm2 through localhost:4200

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search