PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, June 25, 2022

[FIXED] How to proxy requests from client to another server

 June 25, 2022     haproxy, proxy, reverse-proxy     No comments   

Issue

I am working on a mobile app that will get some information from 3rd party API. API only accepts requests from certain IPs, that's why I am trying to build a proxy server that will work like below:

A -> Mobile Clients (IP: 1.1.1.1)
B -> Proxy Server (IP: 2.2.2.2)
C -> 3rd Party API (myapisite.com/*)

Basically, every request from A to C needs to go through B since C only accepts requests from B's IP. I've tried to build it via HAProxy but couldn't manage with domain names. I need a routing mechanism like below:

HTTP requests to 2.2.2.2/myapi should be forwarded to myapisite.com/api
HTTP requests to 2.2.2.2/myotherapi should be forwarded to myapisite.com/otherapi

What would be the simplest solution? Right now, I am thinking about using Ubuntu as a proxy server.


Solution

Minimal config

listen fe_http
  mode tcp
  timeout client  60s
  timeout connect 2s
  timeout server  5s
  bind :::80 v4v6
  server destservr myapisite.com:80 check


Answered By - Aleksandar
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing