多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

相关推荐
吴声子夜歌5 分钟前
Nginx应用与运维——Nginx代理服务应用实战(TCP/UDP代理)
运维·tcp/ip·nginx
吴声子夜歌10 分钟前
Nginx应用与运维——Nginx缓存服务应用实战(一)
运维·nginx·缓存
海宇数据13 分钟前
零信任架构实战:基于海宇活体识别V步骤1构建自动化考前活体认证网关
运维·人工智能·架构·自动化
帷幕落秋14 分钟前
Mysql备份
运维·数据库
吠品19 分钟前
volatile到底在拦什么:SysTick->VAL读的哪格
java·服务器·开发语言
Fcy6481 小时前
Linux下 传输层协议TCP详解
linux·网络·tcp/ip
回眸&啤酒鸭1 小时前
DeepSeek V4.1 Flash 批量处理实战指南
服务器·前端·javascript
BIM云平台开发1 小时前
DAZ里,如何保存现在姿势,如果调错了,可以重新导回
linux·服务器·前端·daz基础教程
栖凤1 小时前
多 Agent 工作流实践:从单打独斗到协同作战
java·linux·服务器
帷幕落秋2 小时前
Mysql的安装,加固与远程访问
运维·数据库