After seeing a friend operate a subdomain for their university, I wanted to try it myself.
It wasn't as difficult as I thought.
It was possible by assigning ports based on the incoming request's host, using a reverse proxy.
So, I gave it a try.
1. Setting Up Subdomains in Gabia
1) Log in to Gabia and Access DNS Management Tool

First, log in to the Gabia website.
Then click on My Gabia -> Service Management from the top menu, and select DNS Management Tool from the menu.
It might appear just by accessing the My Page.
2) Select Domain and Add Record

In the list, click Settings on the right side of the domain where you want to set up the subdomain.

Then click +Add Record at the bottom to move to the tab.
3) Set A Record
Select A as the record type.
Host | Value |
|---|---|
Enter desired subdomain name | Enter Caddy server's public IP address |
ex: test | ex: 123.123.123.123 |

After entering, click Confirm on the right, and finally click Save to complete the setup.
2. Setting Up Subdomain Response in Caddy on the Server
1) Write the Caddyfile
Open the Caddy configuration file, Caddyfile, and add the following content.
test.example.com {
respond "Hello from test.example.com!"
}
You can set the test.example.com part to your subdomain.
Since there is nothing to assign to the subdomain yet, I set it to output simple text with respond.
2) Restart Caddy Server
Now restart the Caddy server to apply the settings.
brew services restart caddy
Caddy automatically obtains a key for https, so there's no need for separate settings.
Now try accessing my configured subdomain.
If the text appears like below, it's successful.

3. Review
I was curious about how to operate multiple servers on one server, and this time I learned clearly by learning about reverse proxy.
The key is that the host domain is included in the header of the request.
Coding seems to never end; new things to learn keep coming up.
Rather good

댓글을 불러오는 중...