多ip访问多网站

作业要求

配置nginx服务通过ip访问多网站

root@localhost \~\]# systemctl stop firewalled Failed to stop firewalled.service: Unit firewalled.service not loaded. \[root@localhost \~\]# mount /dev/sr0 /mnt mount: /mnt: /dev/sr0 已挂载于 /run/media/redhat/RHEL-9-3-0-BaseOS-x86_64. \[root@localhost \~\]# dnf install firewalld -y 正在更新 Subscription Management 软件仓库。 无法读取客户身份 本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。 BaseOS 2.7 MB/s \| 2.7 kB 00:00 AppStream 3.1 MB/s \| 3.2 kB 00:00 软件包 firewalld-1.2.1-1.el9.noarch 已安装。 依赖关系解决。 无需任何处理。 完毕! \[root@localhost \~\]# systemctl stop firewalld \[root@localhost \~\]# setenforce 0 \[root@localhost redhat\]# dnf install nginx -y 正在更新 Subscription Management 软件仓库。 无法读取客户身份 本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。 上次元数据过期检查:0:00:06 前,执行于 2024年10月20日 星期日 15时52分19秒。 依赖关系解决。 ================================================================================ 软件包 架构 版本 仓库 大小 ================================================================================ 安装: nginx x86_64 1:1.20.1-14.el9_2.1 AppStream 40 k 安装依赖关系: nginx-core x86_64 1:1.20.1-14.el9_2.1 AppStream 574 k nginx-filesystem noarch 1:1.20.1-14.el9_2.1 AppStream 11 k redhat-logos-httpd noarch 90.4-2.el9 AppStream 18 k 事务概要 ================================================================================ 安装 4 软件包 总计:643 k 安装大小:1.8 M 下载软件包: 运行事务检查 事务检查成功。 运行事务测试 事务测试成功。 运行事务 准备中 : 1/1 运行脚本: nginx-filesystem-1:1.20.1-14.el9_2.1.noarch 1/4 安装 : nginx-filesystem-1:1.20.1-14.el9_2.1.noarch 1/4 安装 : nginx-core-1:1.20.1-14.el9_2.1.x86_64 2/4 安装 : redhat-logos-httpd-90.4-2.el9.noarch 3/4 安装 : nginx-1:1.20.1-14.el9_2.1.x86_64 4/4 运行脚本: nginx-1:1.20.1-14.el9_2.1.x86_64 4/4 验证 : nginx-1:1.20.1-14.el9_2.1.x86_64 1/4 验证 : nginx-core-1:1.20.1-14.el9_2.1.x86_64 2/4 验证 : nginx-filesystem-1:1.20.1-14.el9_2.1.noarch 3/4 验证 : redhat-logos-httpd-90.4-2.el9.noarch 4/4 已更新安装的产品。 已安装: nginx-1:1.20.1-14.el9_2.1.x86_64 nginx-core-1:1.20.1-14.el9_2.1.x86_64 nginx-filesystem-1:1.20.1-14.el9_2.1.noarch redhat-logos-httpd-90.4-2.el9.noarch 完毕! \[root@localhost \~\]# systemctl start nginx 三个方法查看是否运行,看监听状态,看端口,看进程 *** ** * ** *** \[root@localhost \~\]# netstat -tunlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:\* LISTEN 34433/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:\* LISTEN 1060/sshd: /usr/sbi tcp 0 0 127.0.0.1:6010 0.0.0.0:\* LISTEN 34333/sshd: root@pt tcp 0 0 127.0.0.1:631 0.0.0.0:\* LISTEN 1058/cupsd tcp6 0 0 :::80 :::\* LISTEN 34433/nginx: master tcp6 0 0 :::22 :::\* LISTEN 1060/sshd: /usr/sbi tcp6 0 0 ::1:631 :::\* LISTEN 1058/cupsd tcp6 0 0 ::1:6010 :::\* LISTEN 34333/sshd: root@pt udp 0 0 0.0.0.0:5353 0.0.0.0:\* 862/avahi-daemon: r udp 0 0 127.0.0.1:323 0.0.0.0:\* 907/chronyd udp 0 0 0.0.0.0:53587 0.0.0.0:\* 862/avahi-daemon: r udp6 0 0 :::5353 :::\* 862/avahi-daemon: r udp6 0 0 ::1:323 :::\* 907/chronyd udp6 0 0 :::43630 :::\* 862/avahi-daemon: r \[root@localhost \~\]# lsof -i:80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 34433 root 6u IPv4 71074 0t0 TCP \*:http (LISTEN) nginx 34433 root 7u IPv6 71075 0t0 TCP \*:http (LISTEN) nginx 34434 nginx 6u IPv4 71074 0t0 TCP \*:http (LISTEN) nginx 34434 nginx 7u IPv6 71075 0t0 TCP \*:http (LISTEN) nginx 34435 nginx 6u IPv4 71074 0t0 TCP \*:http (LISTEN) nginx 34435 nginx 7u IPv6 71075 0t0 TCP \*:http (LISTEN) \[root@localhost \~\]# ps -aux \| grep nginx root 34433 0.0 0.0 10052 948 ? Ss 17:06 0:00 nginx: master process /usr/sbin/nginx nginx 34434 0.0 0.2 13940 5008 ? S 17:06 0:00 nginx: worker process nginx 34435 0.0 0.2 13940 5008 ? S 17:06 0:00 nginx: worker process root 34453 0.0 0.1 221680 2432 pts/1 R+ 17:12 0:00 grep --color=auto nginx \[root@localhost \~\]# nmtui ![](https://i-blog.csdnimg.cn/direct/08433309016a4001ac861de585f91433.png) \[root@localhost \~\]# nmcli connection modify ens160 ipv4.method manual ipv4.addresses 192.168.169.100/24 +ipv4.addresses 192.168.169.200/24 ipv4.gateway 192.168.169.2 ipv4.dns 192.168.169.2 \[root@localhost \~\]# nmcli connection up ens160 ![](https://i-blog.csdnimg.cn/direct/7f0f1fbdcda4448c8d23fdb0f3c3150a.png) \[C:\\\~\]$ ssh 192.168.169.100:22 Connecting to 192.168.169.100:22... Connection established. To escape to local shell, press 'Ctrl+Alt+\]'. Activate the web console with: systemctl enable --now cockpit.socket Register this system with Red Hat Insights: insights-client --register Create an account or view all your systems at https://red.ht/insights-dashboard Last login: Tue Oct 22 17:00:32 2024 from 192.168.169.1 \[root@localhost \~\]# vim /etc/nginx/conf.d/test_ip.conf \[root@localhost \~\]# vim /etc/nginx/conf.d/test_ip.conf \[root@localhost \~\]# mkdir /test/{100,200} -pv mkdir: 已创建目录 '/test' mkdir: 已创建目录 '/test/100' mkdir: 已创建目录 '/test/200' \[root@localhost \~\]# echo this is 100 \> /test/100/index.html \[root@localhost \~\]# echo this is 200 \> /test/200/index.html \[root@localhost \~\]# systemctl restart nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. \[root@localhost \~\]# vim /etc/nginx/conf.d/test_ip.conf \[root@localhost \~\]# cat /etc/nginx/conf.d/test_ip.conf server{ listen 192.168.169.100:80; #server_name root /test/100; location /{ index index.html; } } server{ listen 192.168.169.200:80; #server_name root /test/200; location /{ index index.html; } } \[root@localhost \~\]# systemctl restart nginx ![](https://i-blog.csdnimg.cn/direct/8ba36cacbda94967b853be2cf6d3d4ba.png) ![](https://i-blog.csdnimg.cn/direct/8d5509a0783840439d7bb2d7c9673428.png)

相关推荐
123过去5 小时前
wifi-honey使用教程
linux·网络·测试工具
志栋智能6 小时前
低成本自动化巡检:7×24小时守护业务稳定
运维·网络·自动化
ToB营销学堂7 小时前
MarketUP | B2B 自动化营销实战:如何打破“营-销”数据孤岛,构建高转化线索流?
运维·自动化
Deitymoon7 小时前
linux——孤儿进程和僵尸进程
linux
CDN3608 小时前
360CDN 全系列产品体验:CDN / 高防 / SDK 游戏盾横向测评
运维·安全·游戏
行者-全栈开发8 小时前
容器化时代来临 - Docker 技术演进与核心价值
运维·docker·容器·cicd·自动化构建·容器化时代
云飞云共享云桌面8 小时前
非标自动化研发成本高?云飞云共享云桌面:1台主机=10台工作站,年省数十万。
大数据·运维·服务器·人工智能·自动化·云计算·电脑
chehaoman9 小时前
Failed to restart nginx.service Unit nginx.service not found
运维·nginx
Linux运维技术栈9 小时前
生产环境Linux应用目录迁移至LVM独立分区 标准化实战方案
linux·运维·服务器·lvm·逻辑卷
feasibility.10 小时前
SSH Agent Forwarding 与 tmux 排障笔记
linux·运维·服务器·经验分享·笔记·ssh