M
M
maximkalga2017-04-20 11:36:04
Django
maximkalga, 2017-04-20 11:36:04

NGINX - how to bind all microservices running on different ports to one domain without subdomains?

RESTFul API consists of microservices. Each microservice is a separate project (Django, DRF). Microservices are running on different ports of the same server: 8000, 8001, 8002...
How to bring all microservices to one domain, where, depending on the URL, the necessary services will be called?
for example:
example.com/api/v1/auth/... - will redirect to 8000
example.com/api/v1/catalog/... - will redirect to 8001
...
I know how to do it on subdomains, but is it possible to do without them?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wexter, 2017-04-20
@maximkalga

location ^~ /api/v1/auth {
    proxy_pass http://127.0.0.1:8000;
    include proxy_params;
}
location ^~ /api/v1/catalog {
    proxy_pass http://127.0.0.1:8001;
    include proxy_params;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question