不同主机上的子目录

发布于 2024-09-09 08:52:04 字数 327 浏览 1 评论 0原文

我在一台服务器上有一个网站 www.example.com 。我想在另一台服务器/主机上创建 www.example.com/blog。

A) 我可以这样做吗? B) 我怎样才能做到这一点?

我读过一些关于使用 Apache 的 mod_proxy、proxypass 和 ProxyPassReverse 的内容,但我对 Apache 或服务器管理没有足够的天赋,无法知道我是否走在正确的道路上。或者,是否有其他选择可以做我想做的事。

需要明确的是,我不需要像 blog.example.com 这样的子域。我知道如何使用 DNS 来做到这一点,但我不相信 DNS 是子目录的一个选项。

I've got a site www.example.com on one server. I'd like to create www.example.com/blog on another server/host.

A) Can I do this?
B) How can I do this?

I've read a bit on using Apache's mod_proxy, proxypass, and ProxyPassReverse, but I'm not gifted enough with Apache or server mgt to know if I'm on the right track or not. Or, if there are other options to doing what I want.

To be clear, I do not want a subdomain like blog.example.com. I know how I COULD do that with DNS, but I don't believe DNS is an option for subdirectories.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦上情书 2024-09-16 08:52:04

在我看来,这不太可行。正如您所说,您需要一个基于代理的解决方案,从博客服务器获取内容并将其提供给用户。

这有一个严重的缺点,即您博客上的任何流量都必须通过您的主要主机,从而消耗带宽、资源和流量。

是否可以选择重定向(即 www.domain.com/blog 进行标头重定向[在浏览器地址栏中可见]到 blog.otherhost.com)?

如果没有,请查看有关 mod_proxy 的文档。反向代理的基本示例看起来已经不错了:

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar 

This is not doable nicely IMO. As you say, you would need a proxy based solution that fetches the content from the blog server and serves it to the user.

That has the serious downside that any traffic on your blog will have to run through your primary host, eating up bandwidth, resources and traffic volume.

Is a redirect (i.e. www.domain.com/blog doing a header redirect [visible in the browser's address bar] to blog.otherhost.com) an option?

If not, check out the documentation on mod_proxy. The basic example for a reverse proxy looks good already:

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文