Let's say I had a few separate HTTP servers made in node, each with a unique ID attached to them. Is there any way to access them with request URLs based on that id? For example:
Server ifjw48n: accessible via http://example.com/ifjw48n
Server ty58u7e: accessible via http://example.com/ty58u7e
It appears you can do this with nginx used as a routing proxy. Similar question in a different stackexchange forum answered here: Routing to various node.js servers on same machine .
From that answer, here's a sample config that does routing based on the URL:
server {
listen 80;
server_name example.com;
location /foo {
proxy_pass http://localhost:9000;
}
location /bar {
proxy_pass http://localhost:9001;
}
location /baz {
proxy_pass http://localhost:9002;
}
}
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.