You say: "I have an application running at http://localhost:6512" but in the context of your question (and of this very answer), it would be better to say:
- I'm running an HTTP daemon listening on port 6512; let's call it my_daemon. Please note that it's not Apache; it's another application;
Also, you say: "[...] a virtual host definition as follows...", and again, it would be better to say:
- I'm also running Apache, configured to listen on port 80 (and obviously NOT listening on port 6512) and with a single VirtualHost defined. Specifically, the VirtualHost defined below [....]
Having said the above (BTW: Am I right? If not, please add comments), you say to have two problems.
As for the first one:
All traffic to this server including http://example.com is being directed to http://localhost:6512
I would say that IF the hostname example.com
resolve to one of the IP addresses of the host running Apache, THEN this is an expected behaviour as:
- the HTTP request generated by launching "http://example.com" is received by Apache (as it's listening on port 80 of the related IP address);
- as there is NOT an explicitely defined VirtualHost with
ServerName example.com
....
- ...Apache will serve the request via the first VirtualHost defined. And...
- as the first virtual-host is "your" one, then the HTTP request is "proxyed" to my_daemon and...
- as such, my_daemon will receive the HTTP request.
So, again, I don't see the problem.
Again, if I'm wrong with some assumptions, please, let me know.
As for your second "problem", I see that it covers two distinct points. First one is:
A request to ldpmarmotta.example.com is being directed to
http://localhost:6512
and, again, this look to me as an expected behaviour, as it's exactly what you configured in your virtual-host.
Second point is:
I was not expecting the URL to change but the response to return on
ldpmarmotta.example.com
I'm not 100% sure of what exactly you're trying to describe but... if I take out my (dusty) crystal-ball, I bet you're facing problems with ProxyPassing: you have your own HTTP daemon running (my_daemon) but you don't want to expose it directly to the Internet. So you put a standard Apache in front of it and... kindly ask Apache to ProxyPass HTTP requests back-and-forth the Internet and your daemon.
In such a scenario.... you simply have to rely on ProxyPass
AND ProxyPassReverse
.
Something like:
ProxyPass / http://localhost:6512/marmotta/
ProxyPassReverse / http://localhost:6512/marmotta/
(BTW: you used ProxyPassMatch
but as the REGEX you defined it's matching... everything, than it's acting exactly like a standard ProxyPass. Hence, I suggest to use the latter, as it's slightly more efficient and more readable).
As for ProxyPass
/ProxyPassReverse
detailed usage.... the web it's literally FULL of detailed tutorial/articles so.... it will be easy, for you, to get deeper to details :-)
HTH.