简体   繁体   English

Apache服务器使用php发送HTTP请求到另一台服务器

[英]Apache server sending http request to another server with php

Scenario: I have two apache web servers with individual address. 方案:我有两个具有单独地址的apache网络服务器。 Say www.server1.com and www.server2.com. 说www.server1.com和www.server2.com。

For example: if a user login into server1.com and fill in a form and that transfers some information to server2.com and redirects him to server2.com 例如:如果用户登录到server1.com并填写表格,并将某些信息传输到server2.com并将其重定向到server2.com

Real life example: Merchant websites which redirects users to payment gate way. 现实生活中的示例:商家网站将用户重定向到付款方式。 and data transferred to gateway server is the amount to be paid. 传输到网关服务器的数据就是要支付的金额。 After payment the gateway server sends the transaction id to merchant website and redirect user back. 付款后,网关服务器将交易ID发送到商家网站,并将用户重定向回去。


My Question: how does server1.com sends a http request from that server to server2.com . 我的问题:server1.com如何将来自该服务器的http请求发送到server2.com。 and that request can be GET or POST whatever that i describe. 无论我描述什么,该请求都可以是GET或POST。 and it should be invisible to the user. 并且用户应该看不见它。

Note: Server i use is ubuntu. 注意:我使用的服务器是ubuntu。 I have full access to the server, if any modules to be installed no problem. 我对服务器具有完全访问权限,如果要安装任何模块都没问题。 Code i use is PHP. 我使用的代码是PHP。

The webservers don't do the connections. 网络服务器不进行连接。 It's the PHP code that does so. 这样做的是PHP代码。 The standard methods is to use CURL . 标准方法是使用CURL However, in some cases, the form that was served up server1 might actually just submit directly to server2. 但是,在某些情况下,提供给server1的表单实际上可能只是直接提交给server2。 It all depends on the merchant's payment setup. 这完全取决于商家的付款设置。

Shouldn't you just redirect the user towards the payment provider? 您不应该将用户重定向到付款提供商吗? I would not want to enter payment information on a site where the URL starts with "http://www.yoursite.com/payment", I want to enter that data to my credit card company's or bank's site and want visual confirmation that I am there by looking at the address bar. 我不想在URL以“ http://www.yoursite.com/payment”开头的网站上输入付款信息,我想将该数据输入到信用卡公司或银行的网站,并希望通过视觉确认我通过查看地址栏在那儿。

Ontopic: you could use CURL to redirect the request, or use mod_proxy to let Apache handle all proxying for you. Ontopic:您可以使用CURL重定向请求,或使用mod_proxy让Apache为您处理所有代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM