AWS EC2 Angular 5 ng serve not connecting via browser

后端 未结 3 1172
花落未央
花落未央 2021-01-14 06:04

I managed to get my Angular 5 app running on AWS EC2 Ubuntu...

Started standard Ubuntu instance, used PuTTy to shell in, installed node, entered the next 4 \"magic l

3条回答
  •  猫巷女王i
    2021-01-14 06:43

    First of all, please note that the built-in webserver in ng-cli is not intended to be used in production. I strongly advise you to find a better solution if this is for production.

    In order to access the site from other devices/ over the internet, you have to instruct ng-cli to serve it at the correct IP-adress. You can do that by running ng serve --host x.x.x.x.

    It will probably work if you enter your servers LAN-IP (depending on your setup). You can find it by running ifconfig.

    However, since you are hosting a static website, an alternative solution is to simply host the app on S3. To do that, run ng build --prod and upload the dist-folder to AWS S3. They have a tutorial for that here.

    Alternatively, you can use something like Apache or nginx to serve your compiled app from your EC2-instance.

提交回复
热议问题