Page MenuHomePhabricator

Create an API request proxy so that Tool Labs tools can access the Yandex API from a single IP address
Closed, ResolvedPublic5 Estimated Story Points

Description

Per T125459, we should create an API request proxy so that Tool Labs tools can access the Yandex API from a single IP address, as their API only allows one IP per subscription.

Event Timeline

@bd808: How hard would it be to build some kind of API proxy on Labs for the Yandex search API (so that we can access it via Tool Labs through a single IP)?

I think it would take something like:

  • Creating a new Labs project (easy)
  • Allocating a static IP to the project (needs Labs admin approval)
  • Building a the proxy service itself (???)
  • Configuring the proxy service to use the static IP for outbound TCP communications (probably not too hard)
  • Opening inter-project firewall to allow Tools to access the client facing side of the proxy (easy)

The obvious downside of all that is that you then have a single point of failure for all of the Yandex search activity. If that's the only way to get access to the service though I guess it would be a problem that we'd have to live with. The only other things I can think of would require networking voodoo and buy-in from the tech ops team.

  • Building a the proxy service itself (???)
  • Configuring the proxy service to use the static IP for outbound TCP communications (probably not too hard)

It looks like these two bits might be as easy as installing nginx and configuring it to proxy to Yandex:

location / {
    proxy_bind <our static public ip here>;
    proxy_pass <url to root of Yandex here>;
}

I have a proxy up and running at https://yandex-proxy.wmflabs.org that will allow access from inside Labs. The proxy will present all requests to https://yandex.ru as being from the ip address 208.80.155.189.

The configuration used on the instance can be found at https://github.com/bd808/labs-yandex-proxy.

@kaldari and @Niharika: I think this is ready for review. You should be able to hit the new proxy from any host in Labs and see it respond. The next logic step would be to follow the instructions at https://tech.yandex.com/xml/doc/dg/task/registration-docpage/ and get a set of credentials for actually using the service.

@bd808: Sorry I didn't get you the docs earlier. Nothing but meetings and interviews today. I can go ahead and register credentials for the service. I set up an account there a couple weeks ago. I just need to know what IP address the requests are going to come from.

OK, the IP address is now registered with Yandex. I'll give it a test soon.

@bd808: Sorry I didn't notice this earlier, but we need to send the requests to https://yandex.com rather than https://yandex.ru. https://yandex.ru is specifically for the Russian-only search feature, while https://yandex.com is for the worldwide search.

@bd808: Sorry I didn't notice this earlier, but we need to send the requests to https://yandex.com rather than https://yandex.ru. https://yandex.ru is specifically for the Russian-only search feature, while https://yandex.com is for the worldwide search.

{{done}}