无法重定向到在其他端口上运行的另一个网站

时间:2019-05-07 22:43:53

标签: redirect apache2 proxypass

我在8080端口上有两个站点 1)本地主机:8080-> mainsite 2)本地主机: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>

1 个答案:

答案 0 :(得分:0)

尝试使用加载模块:

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,并将其保留为/

相关问题