多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

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

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

相关推荐
垂钓的小鱼18 分钟前
用关联图谱做量化选股:让基本面惊喜沿着网络扩散
服务器·php·apache
Lonely 净土6 小时前
Linux 运维文件写入操作
linux·运维·服务器·文件管理
城管不管6 小时前
重生——第十一次面试之挖财一面2026.8.19已OC
java·服务器·jvm·数据库·spring·面试·职场和发展
飞英思特无线充电7 小时前
严苛场景巡检机器人的无线补能设计:点位、BMS、认证与运维边界
运维·机器人
Jimmy_jimi7 小时前
利用nginx代理完成url重定位
运维·nginx
liuyicenysabel8 小时前
多服务上线日记三:
运维·服务器·笔记·学习
吠品9 小时前
Wine 在 Linux 上运行 Windows 软件完整指南
java·linux·服务器
一只鹿鹿鹿9 小时前
大数据中心安全系统解决方案(Word文件)
大数据·运维·物联网·安全·政务
深念Y11 小时前
从 Windows 迁移到 Linux 开发环境的记录
linux·windows·链接·bun·ram·imdisk
AuTumn-L11 小时前
使用 SSH 密钥认证实现安全免密登录
服务器·安全·ssh