ad48 ad48 - 1 month ago 17
Apache Configuration Question

Redirecting on server side in Apache

If this question is unclear or doesn't belong here/is duplicate,let me know.

I have run two servers:one (Apache) on port 80,and second (custom) on port 81.
Now,the custom server is used for some scripting and only listening on /cgi-bin/

Now,i ported my Apache server to a custom url abc.xyz,and added

<VirtualHost *:80>
Redirect "/cgi-bin/" "http://127.0.0.1:81/cgi-bin/"
</VirtualHost>


However,as i go on abc.xyz/cgi-bin/somescript,it redirects me to localhost:81/cgi-bin/somescript on client side.
And as you know,the server on localhost can be acessed only through my computer.

It is somehow possible to redirect a request on server side instead of client ?

Answer

What you are looking for is not for Apache to serve a redirect, but for Apache to act as a reverse proxy.

ProxyPass "/cgi-bin/" "http://127.0.0.1:81/cgi-bin/" should work for you.