简体   繁体   English

NGINX反向代理/ PHP预处理

[英]NGINX reverse proxy / php pre processing

I would somehow solve the following scenario: We have a server nginx acting as a reverse proxy for some apache servers. 我将以某种方式解决以下情况:我们有一个服务器nginx充当某些apache服务器的反向代理。 We should make sure that when a request comes to nginx proxy it is pre processed by a php script that sets some HTTP request headers, based on the URL content, and then the URL is passed to the server apache. 我们应该确保当对Nginx代理的请求到达时,它会由一个php脚本进行预处理,该php脚本根据URL内容设置一些HTTP请求标头,然后将该URL传递给服务器apache。 We should avoid redirects in this process, but I have no idea how I could do it. 在此过程中,我们应该避免重定向,但是我不知道该怎么做。

Thanks a lot... 非常感谢...

[EDIT] Sorry for the vague question. [编辑]对这个模糊的问题表示抱歉。 Our setup is as follows: nginx is used as a balancer for some apache web server. 我们的设置如下:nginx用作某些apache Web服务器的平衡器。 On the web server runs an application that generates the content of e-commerce (and page categories) on the basis of the analysis of the submitted URL. 在Web服务器上运行一个应用程序,该应用程序基于对提交的URL的分析来生成电子商务内容(和页面类别)。 We use a third-party analysis tool that requires a request header valorized with category but the categories are calculated by the php code of the application... I should make that the request processed by nginx will have an header before arriving to apache. 我们使用第三方分析工具,该工具要求使用带有类别的价目表的请求标头,但是类别是由应用程序的php代码计算的……我应该确保由nginx处理的请求在到达apache之前将具有标头。 I can extract the code from the php application and create an intermediate layer but I have no idea how to manage the whole process. 我可以从php应用程序中提取代码并创建一个中间层,但是我不知道如何管理整个过程。 This is a simple draw: Black as-is, in green to-be (or may be-to-be) simple solution draw 这是一个简单的绘制:黑色保持原样,绿色(或可能成为) 简单解决方案绘制

Your question is very vague - and will probably be closed on that basis. 您的问题非常模糊-可能会以此为依据。 My response here is intended as a comment - but its a bit long for the comment box. 我在这里的答复旨在作为评论-但对于评论框来说有点长。

That you are using nginx as a reverse proxy implies that you are somewhat concerned with performance. 您将nginx用作反向代理意味着您在某种程度上关注性能。 While it would be quite possible to implement what you describe, the nature of PHP running in a webserver means that it will be rather inefficient at the task you describe - each incoming web request will require a new connection to the backend webserver. 尽管完全有可能实现您描述的内容,但是在Web服务器中运行的PHP的性质意味着,它在执行您描述的任务时效率很低-每个传入的Web请求都需要与后端Web服务器的新连接。

Presumably there is some application running on or behind the apache webservers - is there a reason you don't implement the required functionality there? 大概在apache网络服务器上或背后运行着一些应用程序-是否有理由不在那里实现所需的功能?

Can you provide examples of the changes you need to apply to requests and responses? 您能否提供您需要应用于请求和响应的更改的示例? It's possible that some of this could be handled by nginx or apache. 其中一些可能由nginx或apache处理。

Alternatively you might have a look at ICAP (rfc3507) which is protocol designed for supporting these kind of transformations. 或者,您可以看看ICAP(rfc3507),该协议旨在支持这些类型的转换。 Although there sre server implementations using PHP, I suspect they will have most of the same performance issues referenced above. 尽管有一些使用PHP的服务器实现,但我怀疑它们会遇到上面提到的大多数相同的性能问题。

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

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