大网数据广告活动
服务器运维问答

Apache Proxying to Subdirectory doesn't work

· 52CE 我爱测

I have a .NET app running on port 5000 and a node.js app running on port 8080. I want to forward requests to the /app directory to the node application. I have the following configuration. <VirtualHost *:443> ProxyPreserveHost On…

问题原文

原帖链接 · dalevross · CC BY-SA 4.0

I have a .NET app running on port 5000 and a node.js app running on port 8080. I want to forward requests to the /app directory to the node application. I have the following configuration.

<VirtualHost *:443>
    ProxyPreserveHost     On
    ProxyPass             / http://127.0.0.1:5000/
    ProxyPassReverse      / http://127.0.0.1:5000/
    ProxyPass             /app/ http://127.0.0.1:8080/
    ProxyPassReverse      /app/ http://127.0.0.1:8080/
    ErrorLog              /var/log/httpd/amnathrig-error.log
    CustomLog             /var/log/httpd/amnathrig-access.log common
    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/amnathrig.app/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/amnathrig.app/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/amnathrig.app/chain.pem
    SSLCACertificateFile /etc/letsencrypt/live/amnathrig.app/chain.pem
</VirtualHost>

However, requests to /app are still being forwarded to the root application. I'm fairly new to this so it might be something obvious.

已采纳解答

原帖链接 · Lacek · CC BY-SA 4.0

According to the mod_proxy docs:

The configured ProxyPass and ProxyPassMatch rules are checked in the order of configuration. The first rule that matches wins.

So, since the first directive in your config is to proxy /, which will match every URI, the second ProxyPass is a no-op. You should sort your ProxyPass rules so that the most specific ones are the first in the config file.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-06-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。