Using Apache as a Reverse Proxy For Digital Ocean Spaces

The Digital Ocean spaces are quite a nice solution to store the files for your website. Here is how to use Apache as a reverse proxy to create user-friendly URLs for your Digital Ocean Spaces files.

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:

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

Previous
Bootstrap 5. Find the Current Breakpoint with JQuery
Next
GoLang. Dealing with time.Time in a Database Agnostic Manner

Keep Reading

Explore more articles and insights

Ork: SSH Server Automation in Go

Ork: SSH Server Automation in Go

Read Article
Deno Deploy Killed My Start Page

Deno Deploy Killed My Start Page

Read Article
Back to Golang: Why I Switched From Static to Dynamic Again

Back to Golang: Why I Switched From Static to Dynamic Again

Read Article
View All Blog Posts