Using Apache as a Reverse Proxy For Digital Ocean Spaces


The Digital Ocean spaces are quite a nice solutionn to store the files for your website. You may store massive amount of files for a fixed amount per month.

However addressing each file with the full path can be quite unwieldy, and difficult to remember - https://myspacename.ams3.digitaloceanspaces.com/logo.png.

Also it is not a very future proof solution, in case you may change the DgitalOcean space name, or you decide to change the provider.

Would it not be much easier to remember and write for instance /media/logo.png instead of https://myspacename.ams3.digitaloceanspaces.com/logo.png

The solution is to use something called reverse proxy

Here is how to do it with Apache:

Language: XML
ProxyRequests Off
ProxyPreserveHost Off

<Proxy *>
  Order deny,allow
  Allow from all
&lt/Proxy>

SSLEngine On
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass /media/ https://myspace.ams3.digitaloceanspaces.com/
ProxyPassReverse /media/ https://myspace.ams3.digitaloceanspaces.com/

Restart the Apache server, and now you can use the user friendly /media prefix to address all your remote files. And if tomorrow you decide to move to another provider or host them on your own cloud server, all you have to do is to update the proxy settings with the new URL endpoints in Apache