Whenever, at any port of entry, the duties on imports cannot, in the judgment of the President, be collected in the ordinary way, or by the course provided in section
218 of this title, by reason of the cause mentioned in said section, he may direct that the customhouse for the district be established in any secure place within the district, either on land or on board any vessel in the district, or at sea near the coast; and in such case the collector shall reside at such place, or on shipboard, as the case may be, and there detain all vessels and cargoes arriving within or approaching the district, until the duties imposed by law on such vessels and their cargoes are paid in cash. But if the owner or consignee of the cargo on board any vessel thus detained, or the master of the vessel, desires to enter a port of entry in any other district where no such obstructions to the execution of the laws exist, the master may be permitted so to change the destination of the vessel and cargo in his manifest; whereupon the collector shall deliver him a written permit to proceed to the port so designated. And the Secretary of the Treasury, with the approval of the President, shall make proper regulations for the enforcement on shipboard of such provisions of the laws regulating the assessment and collection of duties as in his judgment may be necessary and practicable.