Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

port - Apache forwarding request to another server

I want apache to forward request coming to one server to another server. Here is the complete scnario:

There are 3 servers:

  1. Machine A - IP: A.A.A.A - Client machine which wants to call an API there on machine C.
  2. Machine B - IP: B.B.B.B - Intermediate machine
  3. Machine C - IP: C.C.C.C - Machine hosting the API.

API URL: http:// Machine c:8000/v1/customer/....

Connectivity status:

  1. Machine A -> Machine B: Telnet on port 80 - Good
  2. Machine B -> Machine C: Telnet on port 8000 - Good
  3. Machine A -> Machine C: Telnet on port 8000 - Bad

Ideally, from Machine A I want to call an API on machine C, but since I do not have direct n/w connectivity between A and C, I have to take this route.

So I wanted to set up apache server on machine B such that: From Machine A, make an API call - http:// Machine B:80/v1/customer/.... which then forwards it to Machine C on port 8000. C serves the request and sends the response back to A.

The task might be simple but me being new to this apache, if someone can please tell me the solution, it will be great for my tomorrow's deadline :)

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After some research and googling further was able to do it. Here is what I did - might be helpful to those who are facing the same problem:

In httpd.conf file of machine B added the following:

ProxyPass /v1/customer C.C.C.C:8000/v1/customer

ProxyPassReverse /v1/customer C.C.C.C:8000/v1/customer

Thus from the client (machine A) if the call is made as B.B.B.B/v1/customer, then it will be forwarded to C.C.C.C:8000/v1/customer

mod_proxy module is required for ProxyPass.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...