F
F
foundationick2017-09-11 23:56:53
Nginx
foundationick, 2017-09-11 23:56:53

Nginx redirect requests that go to localhost to remote API?

I need requests. to localhost on some port redirect to remote APIs.
In this case, the problem is with throttle( limit requests per second). You need to make requests to the vk API, and you need to set a limit on outgoing requests so as not to exceed the limit. I decided to install NGINX, send requests to localhost / some URL, catch in inginx and throttle for this.
How to configure it, it doesn’t work,
It seems to be

http{
  server {
    listen localhost:8085;

    location /some/path/method {
      proxy_pass http://api.vk.com;
    } }}

I send from the server to localhost:8085/some/path/method I get errors, nothing goes to VK.
only from nginx comes errors Error: cannot GET /some/path/method/wall.get...
how do you know if something was sent to nginx in VK?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Musin, 2017-09-21
@vmpartner

Forwarding a GET request is written correctly, try proxying to your other host and look at the access logs there. To see what nginx does, here is a good description of how to debug https://serverfault.com/a/435575

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question