I have a Next.js application running on two ports 3000
and 3001
,
and I want to use apache 2.4 reverse proxy to achieve this:
https://app.com/* -> localhost:300x/*
https://user.app.com/* -> localhost:300x/user/*
So far my setting is like below:
<VirtualHost app.com:80>
ServerName app.com
<Proxy "balancer://mycluster">
BalancerMember "http://localhost:3000" route=1 retry=10
BalancerMember "http://localhost:3001" route=2 retry=10
</Proxy>
ProxyPass "/" "balancer://mycluster/"
ProxyPassReverse "/" "balancer://mycluster/"
</VirtualHost>
<VirtualHost user.app.com:80>
ServerName user.app.com
<Proxy "balancer://mycluster">
BalancerMember "http://localhost:3000" route=1 retry=10
BalancerMember "http://localhost:3001" route=2 retry=10
</Proxy>
ProxyPass "/" "balancer://mycluster/user/"
ProxyPassReverse "/" "balancer://mycluster/user/"
</VirtualHost>
But whenever I access https://user.app.com
it redirects me to https://user.app.com/user
with 4o4
error
Hopefully someone can point out what I did wrong. Thank you in advance.