How to mount a DB-9 adapter to an enclosure
Those look like they are designed to join two cables together, not in a box or anything, just cable to cable.

Look for a bulkhead or panel mount connector or feedthrough. You might also be able to buy a panel-mount connector and short serial cable in one piece, sometimes called a panel-mount serial extension or similar.

You might have difficulty finding something at your usual supplier, as it's actually quite unusual to use a DB-9 cable inside the case of an appliance.  More usual is to have a DB-9 cable outside, and something cheaper, smaller and more flexible inside - such as a ribbon cable.