【问题标题】:Can't redirect to another website running on different port无法重定向到在不同端口上运行的另一个网站
【发布时间】:2019-09-25 15:12:29
【问题描述】:

我有两个站点在端口 8080 上提供服务 1) 本地主机:8080 -> 主站点 2) localhost:8080/foo -> foosite

我已将所有文件夹放在 /var/www/html 中

现在我在端口 7777 上运行了另一个 node.js 网站

如果我收到请求 localhost:8080/survey-> 这应该重定向到 localhost:7777/examples/react

但它被重定向到 localhost:8080/examples/react

我已启用 proxy 和 proxy_http 并添加了所需的代理路径

<VirtualHost *:8090>    
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ProxyPass /survey http://localhost:7777/examples/react
    ProxyPassReverse /survey http://localhost:7777/examples/react
</VirtualHost>

【问题讨论】:

    标签: redirect apache2 proxypass


    【解决方案1】:

    尝试加载模块:

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    <VirtualHost *:8090>    
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        ProxyPass /survey http://localhost:7777/examples/react
        ProxyPassReverse /survey http://localhost:7777/examples/react
    </VirtualHost>
    

    您还应该在 ProxyPass 和 ProxyPassReverse 中省略域 http://localhost:7777 并将其保留为 /

    【讨论】:

      猜你喜欢
      • 2020-07-30
      • 2020-09-24
      • 1970-01-01
      • 1970-01-01
      • 2018-05-08
      • 1970-01-01
      • 1970-01-01
      • 2012-01-22
      • 2017-05-15
      相关资源
      最近更新 更多