K
K
keddad2020-08-27 15:37:04
Nginx
keddad, 2020-08-27 15:37:04

Nginx - why are locations not working as expected?

I have a set of containers, Nginx works as a reverse proxy. The configuration looks like this

events { }
http {
  client_max_body_size 100M;

  server {
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    server_name somedomain.com localhost;

    location /api/core {
      proxy_pass http://ff_corecomp:3800;
    }

    location ~ (/api/parse|/api/social) {
      proxy_pass http://ff_socialcomp:3800;
    }
    
    location /api/video {
      proxy_pass http://ff_videocomp:3800;
    }
  }
}


I expect that when I make a request to /api/social/whatever, it will be sent to ff_socialcomp. But, judging by the logs, they are sent to ff_videocomp:
ff_videocomp_1   | INFO:     172.18.0.7:52666 - "GET /api/social/generate_204 HTTP/1.0" 404 Not Found
ff_nginx_1       | 172.18.0.1 - - [27/Aug/2020:12:31:26 +0000] "GET /api/social/generate_204 HTTP/1.1" 404 22 "-" "python-requests/2.24.0"


What is the configuration error?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
keddad, 2020-08-27
@keddad

Apparently, the configuration was simply not applied, something related to the docker. I cleaned everything ( https://gist.github.com/bastman/5b57ddb3c11942094f... ), rebuilt everything, now everything works

A
Andrey Burov, 2020-08-27
@BuriK666

location ~ ^/api/(parse|social) {

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question