[英]How build to deploy node app to http server
Is there any way to use express or other nodejs librarys to to design an api and deploy it pasting files as a resource path in a web server just like react.有什么方法可以使用 express 或其他nodejs库来设计 api 并将其部署为web 服务器中的资源路径,就像react.js一样。
My web server just listen on ports 80 and 443. I have pages on domain.com/page1 domain.com/page2.我的 Web 服务器只侦听端口 80 和 443。我在 domain.com/page1 domain.com/page2 上有页面。 and i want to deploy an api listening on domain.com/page3 but i cant install a nodejs server and proxy requests to page3 to it.我想部署一个 api 侦听 domain.com/page3 但我无法安装 nodejs 服务器和代理请求到 page3 到它。
Thanks a lot非常感谢
There can be only one web server listening on a given port.在给定端口上只能有一个 Web 服务器侦听。 You can directly "listen to a path", only a port.你可以直接“监听一个路径”,只有一个端口。
So, if you already have an existing web server running on ports 80 and 443, then these are your options.因此,如果您已经有一个在端口 80 和 443 上运行的现有 Web 服务器,那么这些是您的选择。
http://yourdomain.com/page3
and https://yourdomain.com/page3
directly with your API.修改您现有的 Web 服务器以将您的 API 服务器代码添加到其中,以便它可以直接使用您的 API 处理对http://yourdomain.com/page3
和https://yourdomain.com/page3
请求。http://yourdomain.com/page3
that will redirect requests to your http://yourdomain.com:3000/page3
Express-based API server.您可以向现有的 Web 服务器添加一些中间件,使其成为http://yourdomain.com/page3
的代理,它将请求重定向到基于http://yourdomain.com:3000/page3
Express 的 API 服务器。http://yourdomain.com:3000/page3
.在您自己的单独端口上运行您自己的基于 Express 的 API 服务器,并通过单独的端口直接访问 API 服务器,例如http://yourdomain.com:3000/page3
。http://yourdomain.com/page3
and https://yourdomain.com/page3
to the separate port that your Express-based API server is running on.您可以在现有的 Web 服务器前面安装一个代理,例如 nginx,并让它将传入请求重定向到http://yourdomain.com/page3
和https://yourdomain.com/page3
到基于 Express 的单独端口API 服务器正在运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.