Linux上部署nginx实现多ip访问多网站

1,添加多个ip地址

使用nmtui命令或nmcli命令

nmtui方式:

nmcli方式:

root@localhost ip# nmcli conncetion ipv4.method manual ipv4.address 192.168.79.129/24 + 192.168.79.130/24 + 192.168.79.131 ipv4.gatway 192.68.79.2 ipv4.dns 114.114.114.114

激活网卡配置:

root@localhost ip# nmcli connection up ens160

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)

查看配置是否生效:

2,在/etc/nginx/conf.d/test_ip.conf 配置文件

server{

listen 192.168.79.129:80; -----监听IP地址,端口

root /ip/129;----访问目录文件

location / { ----访问本地/目录

index index.html;----索引文件名,默认 index.html

}

}

server{

listen 192.168.79.130:80;

root /ip/130;

location / {

index index.html;

}

}

server{

listen 192.168.79.131:80;

root /ip/131;

location / {

index index.html;

}

}

3,重启nginx服务

关闭相关服务

root@localhost \~# systemctl stop firewalld

root@localhost \~# setenforce 0

重启配置

root@localhost /# systemctl restart nginx

4,创建相关目录文件

root@localhost /# mkdir /ip/{129,130,131} -pv

mkdir: created directory '/ip'

mkdir: created directory '/ip/129'

mkdir: created directory '/ip/130'

mkdir: created directory '/ip/131'

root@localhost /# echo this is 129 > /ip/129/index.html

root@localhost /# echo this is 130 > /ip/130/index.html

root@localhost /# echo this is 131 > /ip/131/index.html

5,访问网站

相关推荐
skywalk8163几秒前
卡不等于分支:我用 TRAE 宝配合 Hive 跑三张任务卡的一天
运维·人工智能·hive·trae
znnnk4 分钟前
【Fetch】AI 自动化中的应用——从接口请求到数据获取
运维·自动化
开开心心就好11 分钟前
网页图片批量下载工具,输入链接就保存
服务器·算法·leetcode·支持向量机·pdf·ocr·1024程序员节
2501_9272835821 分钟前
同样是自动化立库,堆垛机和四向车差别在哪里?
运维·自动化
手可摘星陳×28 分钟前
10-运维排障篇-无线排障框架与常见故障-诊断矩阵速查
运维·网络
分布式存储与RustFS31 分钟前
Kafka 分层存储落地指南:冷 Segment 自动落到 RustFS 对象存储
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
acd1200932 分钟前
域名解析缓存带来的隐性故障,很多排查都漏掉了这一层
java·运维·nginx
wuminyu34 分钟前
JVM执行引擎学习总结:热点字节码编译成本地机器码
java·linux·c语言·jvm·c++
Z21-X39 分钟前
云原生运维实战笔记:华为云计算与网络类服务全景解析
运维·笔记·学习·云原生·华为云
Sayai39 分钟前
Elasticsearch ingest pipeline 被禁用之后:性能代价、安全治理与数据入库时间的四种替代方案
大数据·运维·安全·elasticsearch·搜索引擎·性能优化