# Configuring a subserver to run out of a directory of a "main" server

**URL:** <https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274>\
**Category:** Help! (Home for newbies)\
**Created:** [September 27, 2025, 12:00pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274 "2025-09-27T12:00:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![retched](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/retched/32/20240_2.png) [@retched](https://forum.virtualmin.com/u/retched)\
**Post date:** [September 27, 2025, 12:00pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/1 "2025-09-27T12:00:34Z")

</div>

| SYSTEM INFORMATION | |
| --- | --- |
| OS type and version | AlmaLinux 9.6 |
| Virtualmin version | 7.40.1 |
| Webmin version | 2.510 |

I currently have my e-commerce site (ZenCart) installed at one domain (I’ll call it www.mydomain.com) and that domain is served via Cloudflare’s DNS. My admin backend is www.mydomain.com/backend. What I wanted to do is serve the front end through Cloudflare (orange cloud icon), but serve the backend via straight processing on a subdomain (grey cloud icon). (This is because when I run certain backend scripts, Cloudflare always drops the connection and serves an error (1016, I believe) despite me increasing my server timeouts or increasing the worker count). (In short, if I remove the domain from Cloudflare or pause Cloudflare’s processing on that domain, it works… with no problem. But if I turn Cloudflare back on… OOPS.)

My question is: does anyone know how to set up the server to serve that one directory via a subdomain? I know I’m going to have to change the configuration of the ZenCart script, but I’m not sure what else needs to be changed.

I tried to create a sub-server of the main server, but for some reason, the Server refuses to point at the right directory.

---

<div class="post-metadata">

**Author:** ![calport](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/calport/32/44_2.png) [@calport](https://forum.virtualmin.com/u/calport)\
**Post date:** [September 27, 2025, 12:12pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/2 "2025-09-27T12:12:45Z")

</div>

I have never done this, but it should work in theory: on your ZenCart virtual server, create an alias. The alias domain must not have anything to do with Cloudflare. Now, you will be able to access your ZenCart website on its usual domain via Cloudflare and you will also be able to access your ZenCart website on the alias domain - but not via Cloudflare.

So use the alias domain for all your admin back-end work.

---

<div class="post-metadata">

**Author:** ![retched](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/retched/32/20240_2.png) [@retched](https://forum.virtualmin.com/u/retched)\
**Post date:** [September 27, 2025, 12:29pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/3 "2025-09-27T12:29:45Z")

</div>

So it has to be an alias subdomain? Should I change the document root of the alias to point to the directory that contains the backend script or is it enough for me to just use backend.mydomain.com\backend?

---

<div class="post-metadata">

**Author:** ![calport](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/calport/32/44_2.png) [@calport](https://forum.virtualmin.com/u/calport)\
**Post date:** [September 27, 2025, 1:11pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/4 "2025-09-27T13:11:30Z")

</div>

I suggest you get it to work in the simplest possible manner and if it works as expected, you could then do complex things by all means.

---

<div class="post-metadata">

**Author:** ![retched](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/retched/32/20240_2.png) [@retched](https://forum.virtualmin.com/u/retched)\
**Post date:** [September 27, 2025, 2:20pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/5 "2025-09-27T14:20:15Z")

</div>

~~Okay so here’s a weird one, could “Website Proxy Settings” also work? That is, create a subserver, but proxy it to the directory of the main virtual server?~~

Nix that. The method mentioned by calport works. Just would need to do a few extra changes.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [September 28, 2025, 2:51am UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/6 "2025-09-28T02:51:15Z")

</div>

An alias does not have a document root of its own. It is the same document root as the parent.

And, an alias is a better/safer solution than having a cPanel style Subdomain, where the subdomain lives in a directory in the parent domain, as you’ve initially asked about.

---

<div class="post-metadata">

**Author:** ![retched](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/retched/32/20240_2.png) [@retched](https://forum.virtualmin.com/u/retched)\
**Post date:** [September 28, 2025, 3:05am UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/7 "2025-09-28T03:05:08Z")

</div>

I guess I was more or less trying to ask, how to point the root of a subserver inside the directory of another server I guess. (I know using subdomains isn’t recommended or advised but I didn’t have a better word to use for it.)

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [September 29, 2025, 6:22pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/8 "2025-09-29T18:22:55Z")

</div>

> [@retched](#):
>
> I know using subdomains isn’t recommended or advised but I didn’t have a better word to use for it.

“subdomain” only means what you’ve described if you’re using an old version of cPanel. No one else calls it that. We used to support that type of “subdomain” in Virtualmin, but it always felt so terrible. I’ll note that cPanel apparently also doesn’t do it that way anymore (I don’t know for sure, I’ve just been told by people who used cPanel in recent years).

But, an alias _is_ pointing inside the directory of another server. It is exactly the same content as the parent. If you want what’s in a subdirectory, just include the subdirectory in your URL.

If you have an application that needs special treatment for `/api` for instance, just make an alias of `api.domain.tld` and change the path to:

`https://api.domain.tld/api`

That’s it. You’re done. Don’t make it complicated or confusing and weird or potentially a security issue.

If you _really_ wanted to make it appear on `https://api.domain.tld` without the subdirectory in the path, you could do a `RewriteRule` with a `RewriteCond` on the `HTTP_HEADER` to point to the subdirectory…still an Alias, it just behaves differently and doesn’t serve everything, only the subdirectory.

---

<div class="post-metadata">

**Author:** ![retched](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/retched/32/20240_2.png) [@retched](https://forum.virtualmin.com/u/retched)\
**Post date:** [October 6, 2025, 3:36pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/9 "2025-10-06T15:36:55Z")

</div>

Fair enough. I wound up keeping it to pointing a non-cached domain instead. It works for what its worth.

---

<div class="post-metadata">

**Author:** ![system](https://cdn.forum.virtualmin.com/uploads/default/original/2X/c/cd96d761e326db4b2bef94886a639109bd7a8e76.svg) [@system](https://forum.virtualmin.com/u/system)\
**Post date:** [October 14, 2025, 3:37pm UTC](https://forum.virtualmin.com/t/configuring-a-subserver-to-run-out-of-a-directory-of-a-main-server/135274/10 "2025-10-14T15:37:53Z")

</div>

Closed on October 14, 2025, 3:37pm UTC

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.
