Reputation: 661
This question already asked but that not solving my issue.
I am trying to run my Angular-7
product using Server Side Rendering
following steps:
ng add @nguniversal/express-engine --clientProject
npm run build:ssr && npm run serve:ssr
After this step it creating the following folders & files:
Next steps in AWS:
After I try to access my project url it shows like this
I don't know how to solve this problem. Thanks in advance.
Upvotes: 2
Views: 2225
Reputation: 1337
The problem here is that apache/nginx as webservers are rendering your output on port 80 by default and not your angular server. Your Angular express server doesn't run on port 80 though (which the browser expects) and for that reason, you have to forward the port it is actually running to port 80 (default http port). Here are some more details:
Nginx: https://eladnava.com/binding-nodejs-port-80-using-nginx/
If you want to host your node app (which Angular ssr is) on AWS, I would personally recommend to use the elasticbeanstalk node bean. This will handle all of this for you by default and you only have to "zip" the folder you have got and upload it. Everything else (including pm2) will be handled by that.
Apache as a proxy: If you want to use apache as a proxy you have to create a virtualhost for your domain and add the following code:
<VirtualHost node.example.com:80>
ServerName node.example.com
ProxyPass / http://localhost:8000/ connectiontimeout=5 timeout=30 # optional timeout settings
</VirtualHost>
Upvotes: 1