简体   繁体   English

用代理重写Apache 2.2

[英]Apache 2.2 rewrite with proxy

Using Apache 2.2 on an older Ubuntu (12.04)... 在较旧的Ubuntu(12.04)上使用Apache 2.2 ...

Would like to have a path that proxies to another domain (but leaving the URL in the browser unchanged). 希望有一个代理到另一个域的路径(但在浏览器中保留URL不变)。 Tried the following since Proxy stuff isn't allowed in htaccess (assuming not for Apache 2.2 but maybe later versions): 由于htaccess不允许使用代理服务器内容,因此尝试了以下方法(假设不是Apache 2.2,而是更高版本):

<VirtualHost *:80>
  ProxyRequests Off
  ProxyPreserveHost On

  SSLProxyEngine on

  <Proxy *>
    Allow from all
  </Proxy>

  ProxyPass /axis <some domain>
  ProxyPassReverse /axis <some domain>
</VirtualHost>

This works but not when target domain redirects. 这有效,但在目标域重定向时不起作用。 For example, if the some domain redirects to /somepath then instead of pointing to http://<my domain>/axis/somepath the result is http:://<my domain>/somepath which isn't defined. 例如,如果某个域重定向到/somepath则不是指向http://<my domain>/axis/somepath ,而是结果未定义的http:://<my domain>/somepath

Question is how to force everything under a path on my domain (eg /axis ) to match up with another domain? 问题是如何强制我域中某个路径(例如/axis )下的所有内容与另一个域匹配?

An app should either know about the URL structure used to access it, be very good at deducing it, or use well-crafted relative URLs (not root-relative) so that it essentially doesn't matter. 应用程序应该知道用于访问它的URL结构,擅长推导它,或者使用精心设计的相对URL(而不是相对于根的URL),这样就基本上无关紧要了。 The issue is that the content must contain the public URLs, otherwise you have to post-process everything, which is difficult and error-prone. 问题是内容必须包含公共URL,否则您必须对所有内容进行后处理,这很困难且容易出错。

Try moving the <some domain> site's content from the root directory to an axis sub-directory. 尝试将<some domain>网站的内容从根目录移动到axis子目录。 You may have to change some things but at least the URL structures will be identical. 您可能需要进行一些更改,但是至少URL结构将是相同的。

If the system is not designed to be run from a sub-directory, you'll have no (reliable) choice other than fix the URLs it creates. 如果系统并非旨在从子目录运行,那么除了修复其创建的URL之外,您没有其他(可靠的)选择。

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

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