host public node js website on amazon AWS LightSail without Bitnami

非 Y 不嫁゛ 提交于 2021-02-11 17:00:28

问题


I have an amazon AWS LightSail instance and have installed Node js downloaded from nodejs.org. Now the setup is complete and I am able to launch my nodejs webpage inside LightSail instance using "http://localhost but when I try to do it using the lightsail public IP from any other laptop, it not getting accessible (getting web error as "This site can’t be reached").

I have set the node js to listen to port 80 which is open by default.

A lot of materials shows that bitnami as a way to do it but can't I use normal node js installation to make the website public. Appreciate any guidance on this


回答1:


Bitnami Engineer here,

You can configure your Nodejs app to use the port 3000 and then configure Apache to ProxyPass the requests to that port. This way you will be able to access your app using http and https. Does that sound good? You will need to run these commands:

  • Create the folders
sudo mkdir -p /opt/bitnami/apps/myapp
sudo mkdir /opt/bitnami/apps/myapp/conf
sudo mkdir /opt/bitnami/apps/myapp/htdocs
  • Create a /opt/bitnami/apps/myapp/conf/httpd-prefix.conf file with this content
Include "/opt/bitnami/apps/myapp/conf/httpd-app.conf"
  • Add this content to the /opt/bitnami/apps/myapp/conf/httpd-app.conf file
ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/
  • Add this line to the /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf file
Include "/opt/bitnami/apps/myapp/conf/httpd-prefix.conf"
  • Restart Apache
sudo /opt/bitnami/ctlscript.sh restart apache

You have more information in our documentation

https://docs.bitnami.com/aws/infrastructure/nodejs/administration/create-custom-application-nodejs/



来源:https://stackoverflow.com/questions/60180680/host-public-node-js-website-on-amazon-aws-lightsail-without-bitnami

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!