Reputation: 587
The Problem
I would like to map a port number to the url of a site over a large range of ports.
That is if I have the following:
mysite:30123
would become something like mysite/30123
For one case I can do this using nginx. I would like to do this for a large number of ports / a dynamic number of ports.
Some Context
I am using Docker Swarm to launch services, each time a service is launched it will be exposed to a random port in a range of ports, can I do this wthout writing a location
for each port number?
Upvotes: 2
Views: 670
Reputation: 73
I know this is an old question, but this solution can help someone.
Nginx configurations:
map $request_uri $port {
~^/your_path/(.*)$ $1;
default '';
}
location /your_path {
proxy_pass http://127.0.0.1:$port;
}
Upvotes: 1