Make a subdomain point to a port such as for a custom service serving http or https

This is a solution rather than a question. @davness says this is technically a supported feature, but that the custom.yaml file isn’t documented. @alento asked me to post the solution here. However, I’m not sure if this is the correct category or if there should be a new category, as this is a supported feature but isn’t related to e-mail features but to the Custom DNS aspect of MIAB.

Note that this solution is only tested with http (and https). I’m not certain how to use SRV records but they are not necessary for http (and https). Therefore, solution will probably not solve the questions (with unconfirmed answers) at:

  • SRV records on mail in a box t/srv-records-on-mail-in-a-box/7409
  • How to setup SRV Records t/how-to-setup-srv-records/2785
    • Note that the solution there is missing the trailing dot, which is required.

I can’t put the full URLs above because a new forum user can only put 2 URLs, and the system counts the parts in code below apparently.

Comment if anything here helps you or if there are changes necessary to solve those issues. A moderator may want to link them back to here–a few days is a pretty short span before the thread is locked.

In the steps, don’t forget to change the following where noted with asterisks:

* Replace “” in all steps below with the domain under which you want to place the subdomain.

** Replace “service” in all steps below with your subdomain.

*** Replace the port number with the port you are using

  • Log in as the MIAB admin.
  • Make a /home/user-data/www/custom.yaml such as:
    /: http://localhost:12345

* ** ***

  • Note that you must put http (https will be handled automatically).
  • Only if the domain doesn’t have any e-mail addresses yet, add a mailbox or alias such as *
  • Add a mailbox or alias such as * **
  • Reload the custom configuration: Go to Web, hit any “Change” button, then “Update”.
  • Under “System”, click TLS (SSL) Certificates, then click the Provision button.

It seemed to take some number of minutes to take effect, but the “Provision” button may have fixed everything if I hadn’t restarted services manually prior to pushing it. The following unanswered questions remain:

  1. The “Provision” button seems to reload nginx, since https worked right away when everything but https worked prior to pushing it. Does systemctl reload nginx need to run at any step?

  2. @alento asks: “Does the need to be run manually after adding the custom.yaml in this case?” @davness answers: “iirc if you run the web update it also reruns dns”

Anyone who knows answers to those two questions, please comment.

Regardless, the steps above result in a subdomain that points to a service running on a custom port, and both http and https work.

1 Like

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