简体   繁体   中英

Deploy Node.js app with Apache porting issue

I'm deploying a simple node.js app and I'm using apache as a web server. I installed apache correctly and the only thing I changed in the httpd.conf file was the DocumentRoot and Directory. I pointed these to the directory of my node application. I restarted apache and when I go to the public IP I only see the apache testing page?? However if i curl the private IP address.. with the port extension (:8000) than it returns the index page of my app. How do I get apache to send the request to the correct port ?

Edit: If I curl just the private IP address it returns the html for the Apache testing page.

You proxy the request from Apache to Node rather than try to make Apache call the node command directly (like you would do with PHP).

You can do this with config like this:

ProxyPass /app http://127.0.0.1:8000

This means if you go to https://www.example.com/app then you will be calling your node service.

You can of course ProxyPass / so everything goes to your node service, but most people find it's best to allow the web server to handle static pages and resources (as its good at that) and then have node return dynamic content - either directly returning HTML or just returning data in JSON format and the front end javascript using that data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM