简体   繁体   English

mod_proxy到同一服务器中的另一个目录/用户?

[英]mod_proxy to another directory / user in the same server?

I currently have a small team (2 people) working on project one of my site: 我目前有一个小组(2人)在我的网站之一上工作:

http://www.example.com/one/ http://www.example.com/one/

I want to be able to assign more teams to future projects, such as team 2 for project two: 我希望能够为将来的项目分配更多的团队,例如项目2的团队2:

http://www.example.com/two/ http://www.example.com/two/

It's sort of like how big corporate sites such as Microsoft.com is being built and managed, different sub-directory (projects) for different teams. 这有点像大型企业站点(如Microsoft.com)的构建和管理方式,针对不同团队的不同子目录(项目)。 Each of the teams has the privileges to run and manage their own project as a sub-directory of the root domain. 每个团队都有特权作为根域的子目录来运行和管理自己的项目。

After some searches, I came about the mod_proxy module of Apache. 经过一些搜索之后,我发现了Apache的mod_proxy模块。 It seems a perfect fit. 看起来很合适。 However as I currently only has one team, or there might be other projects for more teams but the overall traffic is not so much as to need a whole new other server, my question is, how to relay the requests to another directory in the same server? 但是,由于我目前只有一个团队,或者可能会有其他项目供更多团队使用,但总流量却不足以需要一台新的其他服务器,我的问题是,如何将请求中继到同一目录中的另一个目录服务器?

I know I can just set up different directories under different users but I want to be easily scaling out when the traffic actually takes off so I'd prefer using mod_proxy for this because I can actually add more servers when I need to. 我知道我可以在不同的用户下设置不同的目录,但是我希望在流量真正减少时可以轻松地向外扩展,因此我更喜欢使用mod_proxy,因为实际上我可以在需要时添加更多服务器。

ProxyRequests Off
ProxyPass /foo http://internal/bar
ProxyPassReverse /foo http://internal/bar

Wherein internal/bar is located at /home/team1/public_html 其中internal / bar位于/ home / team1 / public_html

Is this possible? 这可能吗? How to make this happen? 如何做到这一点?

Or as per my need, is there any way that's fundamentally better than the mod_proxy approach? 或者根据我的需要,有没有什么方法比mod_proxy方法更好?

There are a few ways to do this but you probably don't have to use reverse proxy unless your keen on having the projects on different ports/host names and don't want the user to know. 有几种方法可以做到这一点,但是除非您热衷于将项目放在不同的端口/主机名上并且不希望用户知道,否则您不必使用反向代理。 Other wise just use Alias 其他明智的做法是使用别名

  1. If using mod_proxy you would want to put the reverseproxy directives in a www.example.com vhost entry, you could also specify a document root for it. 如果使用mod_proxy,则需要将reverseproxy指令放在www.example.com虚拟主机条目中,也可以为其指定文档根目录。 Then setup more vhosts for each of your projects, eg one.example.com. 然后为每个项目设置更多的虚拟主机,例如one.example.com。 Each vhost can have a different DocumentRoot specified. 每个虚拟主机可以指定不同的DocumentRoot。 Note you could accomplish something similar to reverseproxy via Redirect permanent however this would require a dns being setup for the subdomains. 请注意,您可以通过“重定向永久”来完成与反向代理类似的操作,但是这需要为子域设置dns。 With your mod_proxy solution you can just add the subdomains to the hosts file. 使用您的mod_proxy解决方案,您可以将子域添加到hosts文件中。

  2. Use one of the methods mentioned here: https://httpd.apache.org/docs/1.3/urlmapping.html Alias directive, ScriptAliasMatch, User Directories with AliasMatch 使用此处提到的方法之一: https ://httpd.apache.org/docs/1.3/urlmapping.html Alias指令,ScriptAliasMatch,带有AliasMatch的用户目录

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

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