How to forbid direct IP visit to discourse?

where, in the docker?

but when I add ‘return 500’ in the docker nginx configure file, it shows error either visit IP or domain name.

How to do?