Posted under » Apache on 07 July 2024
In simple terms
<VirtualHost *:80>
ServerName www.anoneh.com
ProxyPreserveHost On
ProxyPass / http://0.0.0.0:8080/
ProxyPassReverse / http://0.0.0.0:8080/
</VirtualHost>
Reverse proxy is useful when you have webservers elsewhere. All apache does is fetch the data from the external websites or other ports as if it is local or port 80.
'ProxyPreserveHost On' if you want your host (www.anoneh.com) to stay. However, this will not send any DNS request to http://0.0.0.0:8080. So if you don't get the page you wanted to see, set to 'ProxyPreserveHost Off' to make it work.
Tip : best to create a ficticious host for the actual server to prevent conflict with an actual URL that is available by DNS.
A proxy forwards a client request to a different server or location, while a rewrite internally modifies the request's URL path before passing it to your application. Proxies manage network traffic and routing, whereas rewrites manage URL presentation and internal file mapping.
When to use Proxy: Use when you need to forward traffic to an entirely different server, microservice, or backend API (e.g., routing /api requests to a Node.js backend).
Rewrite: Use when you want to change the requested URL internally to serve a specific file without the user knowing it changed (e.g., making /about load the /about.html file or mapping dynamic URLs cleanly) You can use proxy with mod rewrite and you will can create some cool stuff.
I have used this for Jupyter Notebook, Streamlit, Moodle and Django Channels.