【问题标题】:Apache Reverse Proxy and Virtual Host at the Same Time同时使用 Apache 反向代理和虚拟主机
【发布时间】:2016-10-28 07:46:52
【问题描述】:

我有一个单一 IP 的 VPS。 VPS 应该服务于 3 个网站。站点 1 - www.domain.com 通过 WordPress。 Site2 - sub.domain.com 通过 WordPress。 Site3 - anothersub.domain.com 通过 NodeJS 在 Docker 容器内侦听端口 81。Site1 和 Site2 非常简单,只需要设置虚拟主机。但是,如何为 Site3 设置 Apache?请您提供一个示例或正确的语法吗?

【问题讨论】:

    标签: apache virtualhost reverse-proxy


    【解决方案1】:

    来自 apache 文档 (https://httpd.apache.org/docs/current/vhosts/examples.html#proxy)

    <VirtualHost *:*>
        ProxyPreserveHost On
        ProxyPass        "/" "http://192.168.111.2/"
        ProxyPassReverse "/" "http://192.168.111.2/"
        ServerName hostname.example.com
    </VirtualHost>
    

    对于你的情况:

      <VirtualHost *:80>
            ProxyPreserveHost On
            ProxyPass        "/" "http://localhost:81/"
            ProxyPassReverse "/" "http://localhost:81/"
            ServerName hostname.example.com
        </VirtualHost>
    

    祝你好运!

    【讨论】:

    • 非常感谢! Apache 文档对于新手来说非常混乱。
    猜你喜欢
    • 2021-08-16
    • 2021-01-03
    • 2021-08-30
    • 2019-01-21
    • 2014-12-02
    • 2022-01-23
    • 2016-06-30
    • 2017-09-25
    • 2018-04-05
    相关资源
    最近更新 更多