OpenEuler---web服务(nginx)

本文详细描述了如何基于www.openlab.com创建包含学生信息、教学资料和缴费功能的子界面,以及如何实施访问权限控制(仅限song和tian访问学生信息),同时实现缴费网站的HTTPS加密。涉及到的操作包括Nginx配置、防火墙和SELinux管理,以及使用htpasswd进行用户认证。
摘要由CSDN通过智能技术生成

网站需求:

1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[www.openlab.com/student](http://www.openlab.com/student) 网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)网站访问教学资料,网站访问缴费网站(http://www.openlab.com/money网站访问缴费网站)。
3.要求

(1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
​(2)访问缴费网站实现数据加密基于https访问。

操作步骤:

1.基本配置

关闭防火墙:systemctl stop firewalld

关闭selinux:setenforce 0

安装nginx:yum install -y nginx

开启nginx服务:systemctl start nginx

查看nginx状态:systemctl status nginx

2.主页面配置

创建目录

mkdir -pv /test/www/openlab

页面文件

echo welcome to openlab > /test/www/openlan/index.html

编辑/etc/hosts文件

vim /etc/hosts

添加192.168.162.146 www.openlab.com

使用curl指令测试

curl www.openlab.com

3.配置data子页面

创建目录

mkdir -pv /test/www/openlab/data

echo welcome to data > /test/www/openlab/data/index.html

测试

curl www.openlab.com/data/

4.配置student子页面

要求:学生信息网站只有song和tian两人可以访问,其他用户不能访问

创建目录

mkdir -pv /test/www/openlab/student

echo welcome to student > /test/www/openlab/student/index.html

配置子配置文件

nginx程序目录:

[root@localhost nginx]# tree /etc/nginx

├── conf.d #子配置文件目录

├── default.d

├── fastcgi.conf

├── fastcgi.conf.default

├── fastcgi_params #用以翻译nginx的变量供php识别

├── fastcgi_params.default

├── koi-utf

├── koi-win

├── mime.types #用以配置文件的媒体文件类型

├── mime.types.default

├── nginx.conf #主配置文件

├── nginx.conf.default

├── scgi_params

├── scgi_params.default

├── uwsgi_params #用以配置nginx的变量供python识别

├── uwsgi_params.default

└── win-utf

#nginx服务配置文件nginx.conf的结构

文件配置:

vim  /etc/nginx/conf.d/openlab.conf

/etc/nginx/users即为用户文件

安装htpasswd用以添加用户

yum install -y htpasswd

添加用户

htpasswd /etc/nginx/users song

添加密码即可创建成功

重启nginx服务

systemctl restart nginx

测试

curl www.openlab.com/student/---访问不成功

带用户测试:curl www.openlan.com/student -u song---访问成功

5.配置money文件

要求:访问缴费网站实现数据加密基于https访问

基本配置

mkdir -pv /test/www/money

echo welcome to money > /test/www/money/index.html

配置子配置文件

vim /etc/nginx/conf.d/openlab.conf

生成私钥文件key

密码设置:Enter PEM pass phrase:123456

再次输入:Verifying - Enter PEM pass phrase:123456

生成公钥文件crt

依次输入:国家,省,城市,组织,部门,常用名,邮箱地址。

重启nginx服务

systemctl restart nginx

测试

curl http://www.openlab.com/money/---访问失败

curl https://www.openlab.com/money/ ---成功

curl https://www.openlab.com/money/ -k跳过ssl证书验证

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值