E
E
EmachinesDIMA2021-12-31 10:57:50
Nginx
EmachinesDIMA, 2021-12-31 10:57:50

How can I set an nginx location block other than "/" to avoid conflicts between independent operation of different services?

Can you please tell me how to disable the processing by the nginx server of the root uri location block - "/" ?

I have several services. I implemented them in separate repositories.
"Backend" service and "react-front" service.
Everything is implemented using docker (compose).

If I run services on ports :
ports: 808x:80 - services are available and handle fine.
If I define via expose : 80
then the "root" of the back, then the front is alternately opened, and bundle.js is not processed - it cannot find it.
I need to specify that front opens at the initial path "/front" , avoiding the processing of "/" .

I tried such implementation - https://docs.nginx.

location / {
    try_files $uri $uri/ @front;
}

location @front {
    add_header Content-Security-Policy ...;
        root /var/www/front;
        try_files $uri $uri/ /index.html$is_args$args;
}


but it does nothing.

I know! that it is impossible not to specify the root location block "/", but I do not know how to get around this implementation.

Challenge: Services should work independently and handle back<->front requests.

yes, they are on the same network. And under the hood jwilder and/or traefik.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2021-12-31
@ky0

Well, don't proxy from /to your back, process the root somehow differently (redirect, error code return). Business something.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question