Question

How to point a Cloudflare Domain to a subfolder on DigitalOcean's App Platform

Hi guys,

I have a nuxt app that I deployed using the App Platform. It has different pages in subfolders like

  • app-name.ondigitalocean.app/website1
  • app-name.ondigitalocean.app/website2

Now I bought a cloudflare domain and used CNAME to point the domain to app-name.ondigitalocean.app. What I would like to achieve now is, that I would like to point my domain example.com to one of the subfolders.

  • example.com should serve the content from app-name.ondigitalocean.app/website1
  • example.com/hello should serve the content from app-name.ondigitalocean.app/website1/hello

From the domain perspective I read about redirects, workers and more, but I didn’t manage to achieve what I wanted. Now I would like to look for the possibilities from digitalocean perspective. I think nginx proxying should help me achieve what I need, but is that also possible on the App Platform?

I would be happy so get some directions on what I could take a look at.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 18, 2024

Hi there,

A quick way to achieve this would be to use a $4 Droplet with Nginx and setup your proxy rules on there, eg:

server {
    listen 80;
    server_name example.com;

    location / {
        proxy_pass http://app-name.ondigitalocean.app/website1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

That way you can point your DNS to the Droplet’s IP address and you can add as many domains as you need.

Instead of a Droplet, you might be able to achieve this with a Dockerfile and a service deployed on the App Platform:

https://docs.digitalocean.com/products/app-platform/reference/dockerfile/

But what I would personally advise you here is to just have two separate apps for each project. That way you can take advantage of the native App Platform routing and domain mapping instead of having to manage a separate reverse proxy service.

Is there a specific reason or a limitation why you need the two sites deployed under the same app instead of separate ones?

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel