本文介绍了如何使用apache将两个不同的路径路由到同一服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑两个网址:

  1. www.mysite.com/*
  2. www.mysite.com/browse/*

后端运行在 http://localhost:8080

如何确保所有具有以下模式的请求都将在我的后端出现,如下所示?

How can I make sure that all requests with following pattern will end up at my backend like below?

示例:

www.mysite.com/doA->本地主机:8080/doA

www.mysite.com/doA --> localhost:8080/doA

www.mysite.com/browse/doA->本地主机:8080/doA

www.mysite.com/browse/doA --> localhost:8080/doA

因此,基本上www.mysite.com/doA和www.mysite.com/browse/doA都会产生相同的结果.

So basically both www.mysite.com/doA and www.mysite.com/browse/doA result in the same thing.

我想使用apache服务器.我可以使用proxy_http重定向一个.但不适用于两个或多个网址:

I want to use apache server. I can redirect one using proxy_http. But it doesn't work for two or more urls:

这是我的配置,适用于一个网址

This is my config that work for one url

<VirtualHost *:80>
  ProxyPass         /  http://localhost:8080/
  ProxyPassReverse  /  http://localhost:8080/
  ProxyRequests     Off
  <Proxy http://localhost:8080/*>
    Order deny,allow
    Allow from all
  </Proxy>
</VirtualHost>  

推荐答案

这应该有效:

<VirtualHost *:80>
ServerName example.com
ProxyRequests     Off
ProxyPass         /browse/ http://localhost:8080/
ProxyPass         /        http://localhost:8080/
ProxyPassReverse  /        http://localhost:8080/
</VirtualHost>

这篇关于如何使用apache将两个不同的路径路由到同一服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 10:07