How to organize subdomains on my project?

Hello everyone,
I want to understand how I can setup different subdomains for different user groups. Project that I am working on is a type of marketplace, where two different user groups (company and customer) needs to have different subdomains to access to the app, such as;

I’ve read about using Virtual Host on Apache, and a lot of related discussion on stackoverflow but I cant seem to wrap my head around this.

I understand that I need to first add CName record through my domain registrar, then VirtualHost block for each subdomain to the httpd.conf file and point to the document root.

How this virtualhost block should look like and how my project folder should be setup? Any direction would be greatly appreciated.


Edit: I use docker containers for environment and DigitalOcean for hosting.

Maybe this helps:

Hi Patrick,
Thank you for the direction, although I couldn’t apply that method (requires 3 diff containers which makes it hard for me to manage deployment via Wappler), it helped me to understand.

I ve managed to add a “.conf” file to sites-available directory on my live web server by following this article. And I pointed to a subfolder inside of my project folder. This is my vhost block;

<VirtualHost *:80>
DocumentRoot /var/www/html/folder1

This worked and I was able to access online, but the .conf file I created on the web server is deleted on my next deploy from Wappler.

When I deploy my container to the remote server on Digital Ocean, is my web server settings getting reset?
Also, since I pointed this subdomain to a subfolder in my project, I had issues with urls having subfolder names such as
Is this something I can figure out with url rewriting/routing in Wappler?

I just tested this and added new file to the /etc/apache2/sites-available directory in live web server(digital ocean container), then I deployed to the live server target. It deleted the file I added.

@Teodor, I ve read about your post and I was wondering if this is how it supposed to be? Every time I deploy docker container to the remote target on Digital Ocean, my web server files is defaulted, meaning that any file I added is getting deleted.

Maybe this will help you:

And this:

Hi George,
I was able to use mount bind and share a directory in my host to my assets folder.
This solved my problem with data staying after rebuilds. This is what I added to my docker-compose.yml file under web services;

- ‘/home/data:/var/www/html/assets/data’

Surely, I had permission error when I tried to upload files to this folder via web client. I fixed this issue by giving permission to anyone (chown -R 777).

I read that this is not a good fix, meaning that it creates security risks. Is there any way you can help me to map user permission from docker container to the host.

I visited almost all sources on the web, but really I coulnt figure out. Seems like this is very controversial issue, where everyone suggest different approach and most of them doesn’t really apply to our situation as Wappler users.

This discussion on stackoverflow gives some options to solve this issue. Maybe the image Wappler use to create docker container (wapplerio/php-7.3-apache) can be changed and somehow it creates docker containers as a specific user from the host, that has proper permissions?

I am sorry, I am new to this and having hard time to understand, maybe I should look for just a regular hosting.