当前位置: 代码网 > 服务器>服务器>Nginx > nginx基于IP的多虚拟主机实现

nginx基于IP的多虚拟主机实现

2024年05月19日 Nginx 我要评论
结合这篇文章一起:环境准备配置好两个ip地址,给网络设备添加别名,绑定多个ipifconfig ens33:1 192.168.1.50 netmask 255.255.255.0 broadcast

结合这篇文章一起:

环境准备

配置好两个ip地址,给网络设备添加别名,绑定多个ip

ifconfig ens33:1 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255 up

配置

/usr/local/nginx/conf/extra/server_80.conf

server {
        listen 192.168.1.50:80;
        server_name localhost;
        location /{
                root html/server_50;
                index index.html;
        }
}

配置完后:

检查:nginx -t

重新加载配置:nginx -s reload

创建server_50目录

/usr/local/nginx/html/server_50/index.html

<!doctype html>
<html>
<head>
<title>welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: tahoma, verdana, arial, sans-serif; }
</style>
</head>
<body>
<h1>welcome to server_50!</h1>

<p><em>thank you for using nginx.</em></p>
</body>
</html>

测试:

到此这篇关于nginx基于ip的多虚拟主机实现的文章就介绍到这了,更多相关nginx ip多虚拟主机内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com