在 Apache 中设置反向代理的问题

发布于 2024-07-16 15:06:45 字数 553 浏览 7 评论 0原文

我和我的室友都有一个单独的网络服务器,我们正在尝试设置。 我们正在尝试使用 mod_proxy,以便他的服务器根据服务器名称将请求转发到我的机器(我们在一台路由器后面有两台单独的机器)。 我已经给出了当前 apache 配置中的基础知识,但在尝试访问第二个域(第一个 www 域工作正常)时,我们收到 403 Forbidden 错误。

NameVirtualHost *:80

<VirtualHost *:80>
 DocumentRoot /var/www
 ServerName www.<domain1>.com
</VirtualHost>

<VirtualHost *:80>
 ProxyPreserveHost On
 ProxyPass / http://<IP addr of other box>:80
 ProxyPassReverse / http://<IP addr of other box>:80
 ServerName <dummydomain>.gotdns.com
</VirtualHost>

My roommate and I each have a separate webserver we are trying to set up. We are trying to use mod_proxy so that his server will forward requests to my machine (we have two seperate machines behind one router) based on the server name. I've given the basics of what we have in our apache config currently but we are getting a 403 Forbidden error when trying to access the second domain (the first, www domain, works fine).

NameVirtualHost *:80

<VirtualHost *:80>
 DocumentRoot /var/www
 ServerName www.<domain1>.com
</VirtualHost>

<VirtualHost *:80>
 ProxyPreserveHost On
 ProxyPass / http://<IP addr of other box>:80
 ProxyPassReverse / http://<IP addr of other box>:80
 ServerName <dummydomain>.gotdns.com
</VirtualHost>

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

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

发布评论

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

评论(2

变身佩奇 2024-07-23 15:06:45

您的 mods-enabled/proxy.conf 可能会阻止任何代理请求(默认情况下拒绝所有请求)。 它应该包括以下内容:

ProxyRequests Off

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

编辑:还要确保 mod_proxy 子模块符号链接到 mods-enabled (在这种情况下,http 子模块是 mods-available/proxy_http.load)

Your mods-enabled/proxy.conf might be blocking any proxy requests (it's deny all by default). It should include the following instead:

ProxyRequests Off

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

EDIT: Also make sure that the mod_proxy submodules are sym linked into mods-enabled (in this case, the http sub module which is mods-available/proxy_http.load)

瑾夏年华 2024-07-23 15:06:45

只需输入两条路线:

<VirtualHost *:80>
    DocumentRoot "/app/"
    ProxyPreserveHost On
    ProxyRequests Off
    ServerName app.yourdomain.com

    ProxyPass /app http://yourIP:yourPort/app/
    ProxyPassReverse /app http://yourIP:yourPort/app/

    ProxyPass / http://yourIP:yourPort/app/
    ProxyPassReverse / http://yourIP:yourPort/app/
</VirtualHost>

<Location "/app/" >
    ProxyPass "http://yourIP:yourPort/app/"
    ProxyPassReverse  "http://yourIP:yourPort/app/"
    ProxyPassReverseCookiePath  "/app/"  "/app/"
    ProxyHTMLEnable Off
    ProxyHTMLExtended On
    ProxyHTMLURLMap "/app/" "/app/"
    Order allow,deny
    Allow from all
</Location>

这对我有用

Just put both routes:

<VirtualHost *:80>
    DocumentRoot "/app/"
    ProxyPreserveHost On
    ProxyRequests Off
    ServerName app.yourdomain.com

    ProxyPass /app http://yourIP:yourPort/app/
    ProxyPassReverse /app http://yourIP:yourPort/app/

    ProxyPass / http://yourIP:yourPort/app/
    ProxyPassReverse / http://yourIP:yourPort/app/
</VirtualHost>

<Location "/app/" >
    ProxyPass "http://yourIP:yourPort/app/"
    ProxyPassReverse  "http://yourIP:yourPort/app/"
    ProxyPassReverseCookiePath  "/app/"  "/app/"
    ProxyHTMLEnable Off
    ProxyHTMLExtended On
    ProxyHTMLURLMap "/app/" "/app/"
    Order allow,deny
    Allow from all
</Location>

This worked form me

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