A
A
Alexander Epikhin2020-09-29 15:52:51
Nginx
Alexander Epikhin, 2020-09-29 15:52:51

How to configure proxy_pass on nginx?

При таком nginx конфиге
location  /fake {
        proxy_pass http://fake:3050;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}

Такой запрос /fake/product/Pirozhnoe_kartoshka проксируется на http://fake:3050 по такому же урлу http://fake:3050/fake/product/Pirozhnoe_kartoshka , а нужно на http://fake:3050/product/Pirozhnoe_kartoshka
Как этого можно достичь?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Epikhin, 2020-09-30
@leshiple

The problem was solved in this way:

location  /fake {
        proxy_pass http://fake:3050;
        rewrite /fake(.*)$ $1 break;
}

Z
zohan1993, 2020-09-29
@zohan1993

location ~ ^/fake/(?<fwd_path>.*)$ {
        proxy_pass http://fake:3050/$fwd_path$is_args$args;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question