Hi! It’s a little unclear what you’re after. If you can expand on your question with some more details, it would help us to better answer it. What are you using as your web server? Apache? Nginx?
Nameservers generally listen on port 53 while HTTP listens on port 80. Assuming you have A records pointing both ns1.mydomain.com and www.mydomain.com to the same IP address, there’s no way to disable HTTP access completely. Though you could make a 403 Forbidden error for requests to ns1.mydomain.com. You could use something like:
<VirtualHost *:80>
ServerName www.mydomain.com
DocumentRoot /var/www/html
# The rest of you VirtualHost configuration....
</VirtualHost>
<VirtualHost *:80>
ServerName ns1.mydomain.com
<Location />
Order allow,deny
Deny from all
</Location>
</VirtualHost>