在 CentOS(以及大多数 Linux 系统)里,“隐藏域名”通常有几种不同含义,下面按常见场景分别说明,你可以对号入座。
✅ 适合:内部服务器、测试环境
例如:
real.example.comwww.example.comNginx 示例
server {
listen 80;
server_name www.example.com;
location / {
proxy_pass http://real.example.com;
proxy_set_header Host real.example.com;
}
}
外部只看到 www.example.com,不知道后端域名。
server_tokens off;
proxy_redirect http://real.example.com/ /;
hostname
hostnamectl set-hostname localhost
编辑:
vi /etc/hosts
避免写真实业务域名,例如:
127.0.0.1 localhost
vi /etc/ssh/sshd_config
DebianBanner no
重启:
systemctl restart sshd
myhostname = mail.localhost
可只记录 IP:
log_format main '$remote_addr - $request';
firewall-cmd --add-service=dns --permanent
firewall-cmd --reload
对外隐藏域名 = 不解析 DNS + 反向代理 + 修改 banner + 清理 hosts
如果你能具体说:
我可以给你更精确的 CentOS 配置示例。