M
M
maxalx2019-12-14 13:25:58
Nginx
maxalx, 2019-12-14 13:25:58

How to configure proxy_pass on nginx (Bitrix VM)?

It is necessary to transfer the domain.com/api/... request from the machine on which BitrixVM is installed (for example, 1.1.1.1) to another machine via the local network (for example, 192.168.123.123).
For example, when a request is made, the request
http://1.1.1.1/api/method/arg/?param=1
must be executed on another machine
http://192.168.123.123:80/api/method/arg/?param=1
Added location in the file /etc/nginx/bx/site_enabled/s1.conf the following location:

server {
...
    location ~/api/(.*)$ {
        proxy_pass http://192.168.123.123;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_redirect default;
    }
...
}

Now, when requesting:
http://1.1.1.1/api/method/arg/?param=1
page 502 Bad Gateway Bitrix Environment is returned.
Although, when requesting from BitrixVM:
curl http://192.168.123.123/api/method/arg/?param=1

the request is executed and data is received from the local machine (there are no errors on the second machine)
There is very little experience in configuring nginx. Tell me which nginx config file in BitrixVM needs to be edited, how to write location correctly, or at least in which direction to dig. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-12-14
@ky0

Everything is correct in the config. Request from the server, where does nginx http://192.168.123.123/api/method/arg/?param=1go?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question