Web服务器实战

news2024/9/30 5:29:50

网站需求

1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个网站目录分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料
www.openlab.com/money网站访问缴费网站。
3.要求:
(1)学生信息网站只有song和tian两人可以访问,其他网站所有用户用能访问。
(2)访问缴费网站实现数据加密基于https访问。

准备

1.需要两台Linux虚拟机,一台为服务端server,另一台为客户端client
server IPV4:192.168.110.136/24                client  IPV4:192.168.110.134/24
2.服务端需要关闭防火墙和Linux的安全服务seLinux
[root@server ~]# systemctl stop firewalld
[root@server ~]# setenforce 0
[root@server ~]# getenforce 
Permissive

3.安装httpd,mol_ssl
[root@server ~]# yum install -y httpd mod_ssl

配置

1.客户端通过IP地址可以正常访问服务端内容

[root@server ~]# mkdir -v /openlab/                       #创建目录
已创建目录 '/openlab/' 
[root@server ~]# echo "welcome to openlab!!!" > /openlab/index.html  #写入内容 
[root@server ~]# vim /etc/httpd/conf.d/openlab.conf            #打开httpd的额外参数配置文件 

<Directory "/openlab/">
        Options Indexes FollowSymLinks                                       
        AllowOverride None  

        Require all granted                 
</Directory>

<VirtualHost 192.168.110.136:80>
    ServerAdmin admin@outlook.com
    DocumentRoot "/openlab/"
    ServerName www.openlab.com
</VirtualHost>
[root@server ~]# httpd -t               #语法检测
Syntax OK
[root@server ~]# systemctl restart httpd         #重启服务

客户端访问

[root@client ~]# curl 192.168.110.136
welcome to openlab!!!

2.搭建学生信息,教学资料,缴费网站页面

[root@server ~]# mkdir /openlab/{student,data,money} -v
mkdir: 已创建目录 '/openlab/student'
mkdir: 已创建目录 '/openlab/data'
mkdir: 已创建目录 '/openlab/money'

[root@server ~]# echo "学生信息" > /openlab/student/index.html      #写入内容
[root@server ~]# echo "教育网站" > /openlab/data/index.html           #写入内容
[root@server ~]# echo "缴费网站" > /openlab/money/index.html       #写入内容

首先配置student页面只有song和tian用户访问

[root@server ~]# htpasswd -c /etc/httpd/conf.d/httpd song    #创建sond的身份验证文件
New password: 
Re-type new password: 
Adding password for user song
[root@server ~]# htpasswd /etc/httpd/conf.d/httpd tian      #添加tain的身份验证文件
New password: 
Re-type new password: 
Adding password for user tian

[root@server ~]# cat /etc/httpd/conf.d/httpd
song:$apr1$XWPO6i0/$hNsM5W/Gx3ukFsPokAEEH.
tian:$apr1$SSblX1SO$YGyWDIuzZmCuLfhBnqn6m1

[root@server ~]# vim /etc/httpd/conf.d/openlab.conf    #在额外参数配置文件添加内容

<VirtualHost 192.168.110.136:80>
    ServerAdmin admin@outlook.com
    DocumentRoot "/openlab/student"
    ServerName www.openlab.com
</VirtualHost>
<Directory "/openlab/student">
        Options Indexes FollowSymLinks
        AllowOverride None
        AuthType Basic
        AuthName "Restricted Files"
        AuthUserFile "/etc/httpd/conf.d/httpd "    #身份验证文件的路径
        Require user song tian                         #允许访问的用户

</Directory>
[root@server ~]# httpd -t                             #语法检测
Syntax OK
[root@server ~]# systemctl restart httpd   #重启服务

客户端访问

[root@client ~]# curl 192.168.110.136/student/ -u song
Enter host password for user 'song':
学生信息
[root@client ~]# curl 192.168.110.136/student/ -u tian
Enter host password for user 'tian':
学生信息


其他用户访问

配置教学资料网站所有用户都可访问

[root@server ~]# vim /etc/httpd/conf.d/openlab.conf   #打开配置文件添加内容

<Directory "/openlab/data/">
Options Indexes FollowSymLinks
  AllowOverride None
Require all granted
</Directory>

<VirtualHost 192.168.110.136:80>
    ServerAdmin admin@outlook.com
    DocumentRoot "/openlab/data/"
    ServerName www.openlab.com
</VirtualHost>
[root@server ~]# httpd -t
Syntax OK
[root@server ~]# systemctl restart httpd
 

客户端访问

[root@client ~]# curl 192.168.110.136/data/
教育网站

配置缴费网站实现数据加密基于https访问

[root@server ~]# cd /etc/pki/tls/certs/                         #存放着一些证书文件

[root@server certs]# openssl genrsa 2048 >> openlab.key    #生成私钥文件
[root@server certs]# openssl req -utf8 -new -key openlab.key -x509 -days 100 -out openlab.crt     #生成证书
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:SN         #国家
State or Province Name (full name) []:CN     #省份
Locality Name (eg, city) [Default City]:XI'AN        #城市     
Organization Name (eg, company) [Default Company Ltd]:OPENLAB    #企业
Organizational Unit Name (eg, section) []:RHCE        #部门
Common Name (eg, your name or your server's hostname) []:www.openlab.com 域名
Email Address []:admi@outlook.com            #邮件
[root@server ~]# vim /etc/httpd/conf.d/openlab.conf

<VirtualHost 192.168.110.136:443>
    DocumentRoot "/openlab/money/"
    ServerName www.openlab.com
    SSLEngine on
    SSLCertificateFile "/etc/pki/tls/certs/openlab.crt"
    SSLCertificateKeyFile "/etc/pki/tls/certs/openlab.key"
</VirtualHost>

<Directory "/openlab/money/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
[root@server ~]# httpd -t
Syntax OK
[root@server ~]# systemctl restart httpd

客户端访问

[root@client ~]# curl https://192.168.110.136 -k    #-k为忽略证书访问
缴费网站
[root@client ~]# curl 192.168.110.136/money/ -k 
缴费网站

/etc/httpd/conf.d/openlab.conf配置文件最终内容

3.客户端通过域名可以正常访问服务端内容

在没有DNS域名解析服务器的情况下可以使用本机hosts文件,hosts文件其作用就是将一些常用的网址域名与其对应的IP地址建立一个关联"数据库"

在Linux下hosts文件地址为/etc/host

[root@client ~]# vim /etc/hosts                        #写入内容

192.168.110.136        www.openlab.com

[root@client ~]# curl www.openlab.com
welcome to openlab!!!
[root@client ~]# curl www.openlab.com/student/ -u song
Enter host password for user 'song':
学生信息
[root@client ~]# curl www.openlab.com/student/ -u tian
Enter host password for user 'tian':
学生信息
[root@client ~]# curl www.openlab.com/data/
教育网站
[root@client ~]# curl https://www.openlab.com -k
缴费网站
[root@client ~]# curl www.openlab.com/money/ -k
缴费网站

在Windows客户端下hosts文件路径为C:\Windows\System32\drivers\etc\hosts  

添加内容,浏览器访问即可,因为www.openlab.com该域名已存在所以浏览器无法访问

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1181081.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

DDD领域模式的模块层级及其依赖关系

DDD领域模型设计是一种常用的软件设计模式,它强调将业务逻辑和数据模型放在最核心的位置,以便更好地满足业务需求。在DDD领域模型设计中,应用程序被分为四个层次:用户界面层、应用服务层、领域模型层和基础设施层。 层次 用户界面层(Presentation Layer) 作为用户和应…

思维训练4

题目描述1 Problem - A - Codeforces 题目分析 对于此题我们要求差值种类最大&#xff0c;故我们可以构造出相邻差值分别为1&#xff0c;2&#xff0c;3...由于n规定了最大的范围故我们增到一定的差值之后其差值必定为之前出现过的数字&#xff0c;但由于要保证数组呈递增趋势…

java项目之线上教学平台(springboot框架)

项目简介 线上教学平台实现了以下功能&#xff1a; 管理员&#xff1a;首页、个人中心、学员管理、资料类型管理、学习资料管理、交流论坛、我的收藏管理、试卷管理、留言板管理、试题管理、系统管理、考试管理。学员&#xff1a;首页、个人中心、我的收藏管理、留言板管理、…

优思学院|APQP(先期产品质量规划)简介

在汽车行业&#xff0c;APQP Advanced Product Quality Planning&#xff08;先期产品质量规划&#xff09;&#xff0c;是一种常用的质量规划指南和工具&#xff0c;但它同样适用于其他行业。APQP是汽车国际行动组织&#xff08;AIAG&#xff09;提出的一种方法&#xff0c;用…

百数低代码与AI:实现业务智能化的新途径

今年6月&#xff0c;咨询机构麦肯锡发布了的一份题为《生成式人工智能的经济潜力》的研究报告&#xff0c;在报告中&#xff0c;分析师们通过对47个国家及地区的850种职业&#xff08;全球80%以上劳动人口&#xff09;的研究&#xff0c;探讨了在AI成指数级发展背后&#xff0c…

【云原生】使用nginx反向代理后台多服务器

背景 随着业务发展&#xff0c; 用户访问量激增&#xff0c;单台服务器已经无法满足现有的访问压力&#xff0c;研究后需要将后台服务从原来的单台升级为多台服务器&#xff0c;那么原来的访问方式无法满足&#xff0c;所以引入nginx来代理多台服务器&#xff0c;统一请求入口…

在idea命令行,or linux 终端执行命令,快速获取通过脚本上证指数、创业板实时行情

脚本编写 编写shell脚本如下,并保存命名为stock curl http://hq.sinajs.cn/list=s_sh000001 -H User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0 -H Accept: */* -H Accept-Language: en-US,en;q=0.5 --compressed -H Referer…

SIEM 体系结构的组件

安全信息和事件管理&#xff08;SIEM&#xff09;软件可帮助 IT 安全专业人员保护其企业网络免受网络攻击&#xff0c;SIEM 解决方案从组织中的所有基础结构组件收集日志数据&#xff0c;为安全专业人员提供实时数据和对网络活动的见解。 网络的内部视图可以帮助您识别和预防威…

热像仪:使用 ESP32 和 MLX90640 传感器设计您自己的红外成像设备

本文详细介绍如何设计一款基于ESP32的热成像仪,文末包含完整的原理图,PCB,3D文件,程序源码的免费下载链接 使用 ESP32 和 MLX90640 传感器 DIY 热像仪 热像仪广泛应用于各种工业应用,例如热性能监控、检测温度异常、热基准测试等。我们甚至将热成像用于国防和军事应用。我…

Python教程:Pandas删除数据的4种情况

大家早好、午好、晚好吖 ❤ ~欢迎光临本文章 如果有什么疑惑/资料需要的可以点击文章末尾名片领取源码 开始之前&#xff0c;pandas中DataFrame删除对象可能存在几种情况 1、删除具体列 2、删除具体行 3、删除包含某些数值的行或者列 4、删除包含某些字符、文字的行或者列…

2023-11-07 android 编译的时候出现 unused variable ‘temp0‘ [-Werror,-Wunused-variable]

一、android 编译的时候出现 unused variable temp0 [-Werror,-Wunused-variable] 二、解决方法&#xff1a;在android.mk里面添加 LOCAL_CFLAGS -Wno-unused-parameter -Wno-unused-variable 三、解释 -Woption 让编译器给出option指定的编译警告&#xff0c;常用的一些如…

CSS实现文本左右对齐

因为文本里面有中午符号&#xff0c;英文&#xff0c;英文符号等&#xff0c;导致设置宽度以后右侧凌乱&#xff0c;可以通过以下代码设置样式&#xff0c;让文本工整对齐。 让我们看一下设置前和设置后的对比图片&#xff1a; 效果图如下&#xff1a;&#xff08;左边是设置…

揭秘Spring框架:模块装配的奥秘与实战技巧 【Spring|Java】

⭐简单说两句⭐ 作者&#xff1a;后端小知识&#xff0c;CSDN后端领域新星创作者|阿里云专家博主 CSDN个人主页&#xff1a;后端小知识 &#x1f50e;GZH&#xff1a;后端小知识 &#x1f389;欢迎关注&#x1f50e;点赞&#x1f44d;收藏⭐️留言&#x1f4dd; 揭秘Spring框架…

Cocos 进度条物体跟随效果

话不多说上代码&#xff0c;记录一下初学cocos解决的问题&#xff0c;实用小功能。 import { _decorator, Button, Component, Node, ProgressBarComponent, Sprite, UITransform, Vec3 } from cc; const { ccclass, property } _decorator;ccclass(game_scene1) export clas…

容联七陌携手岚时科技,解决医美机构回访3大痛点

近日&#xff0c;岚时科技研发中心联合容联七陌发布了全新的智能呼叫中心系统&#xff0c;5大功能模块解决了医美机构回访过程中的3大难题&#xff1a;客户资产保全困难、客户回访技术被卡脖子、回访人员&#xff08;客服、咨询&#xff09;效率管理困难。 “智能呼叫中心”通过…

ZKP8.1 Polynomial-IOP and Polynomial Commitment Schemes

ZKP学习笔记 ZK-Learning MOOC课程笔记 Lecture 8: FRI-based Polynomial Commitments and Fiat-Shamir (Justin Thaler) 8.1 Polynomial-IOP and Polynomial Commitment Schemes Recall: build an efficient SNARK Recall: Polynomial-IOP P’s first message in the pro…

Freeswitch代码

1.引入依赖 Freeswitch依赖版本 <dependency><groupId>org.freeswitch.esl.client</groupId><artifactId>esl-client</artifactId><version>0.10.1</version> </dependency> 2.代码 import org.freeswitch.esl.client.inbound…

分享导致vcruntime140_1.dll丢失的原因,以及vcruntime140_1.dll的解决办法

电脑中缺失vcruntime140_1.dll文件的问题&#xff0c;是常有的问题&#xff0c;不仅仅是vcruntime140_1.dll文件&#xff0c;还会有很多的其他的dll文件都会出现这样的问题。今天就和大家聊聊vcruntime140_1.dll文件丢失的情况&#xff0c;和什么原因导致的丢失vcruntime140_1.…

【波形图】在波形图上显示相对时间并将原点设置为零

默认情况下&#xff0c;波形图有一个定义的窗口来显示 X 轴。当X值达到该窗口的上限时&#xff0c;图表开始滚动以显示最新值的窗口。为了防止这种情况&#xff0c;请通过右键单击图表并选择X Scale Autoscale X将 X 轴设置为自动缩放。此操作还将增加窗口的大小以显示从 0 到…

基于SSM的智慧作业试题管理系统(有报告)。Javaee项目。

演示视频&#xff1a; 基于SSM的智慧作业试题管理系统&#xff08;有报告&#xff09;。Javaee项目。 项目介绍&#xff1a; 采用M&#xff08;model&#xff09;V&#xff08;view&#xff09;C&#xff08;controller&#xff09;三层体系结构&#xff0c;通过Spring Sprin…