如何使用nginx设置带ip的子域

How to set subdomains whit ip using nginx

Nginx 上的子域是否可以与 ip 一起使用进行测试,例如 teste.x.x.x.x 我这样做了,但没有用。

server_name teste.x.x.x.x teste2.x.x.x.x ;

谢谢

我会说这是不可能的,因为 IP 地址本身就是一个实体,而子域是 DNS 结构或层次结构的一个特征。

但是,出于测试目的,您可以编辑 /etc/hosts 文件,添加以下内容:

x.x.x.x teste.yourdomain.com
y.y.y.y teste2.yourdomain.com

这样,在您的浏览器中访问 teste.yourdomain.com,会将您的请求重定向到 x.x.x.x