RHCE第二次

1、搭建一个通过网址https://www.openlab.com/money访问的缴费网站,网站内容为money

基本操作

#装包
[root@rhce ~]# dnf install nginx -y
#配置IP地址并激活网卡
[root@rhce ~]# nmcli connection modify ens33 +ipv4.addresses  192.168.126.156/24
[root@rhce ~]# nmcli connection up ens33
#创建目录
[root@rhce ~]# mkdir -pv /www/https/money
#将内容写入HTML首页文件
[root@rhce ~]# echo money > /www/https/money/index.html

使用openssl生成自签名的ssl证书

[root@rhce ~]cd /etc/pki/tls/certs/
[root@rhce certs]# openssl  genrsa -out  https.key        #在当前目录下生成一个名为https.key的私钥文件
Generating RSA private key, 2048 bit long modulus (2 primes)
...............+++++
..........................................+++++
e is 65537 (0x010001)
[root@rhce certs]# openssl req -utf8 -new -key https.key -x509 -days 100 -out https.crt        #生成一个新的X.509证书,并与指定的私钥配对
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) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

编辑配置文件

[root@rhce ~]# vim /etc/nginx/conf.d/money.conf
server {
        listen 192.168.126.156:443 ssl;
        server_name www.openlab.com;
        root /www/https;
        ssl_certificate /etc/pki/tls/certs/https.crt;
        ssl_certificate_key /etc/pki/tls/certs/https.key;
        location /money {
                index index.html;
        }
}

IP地址被映射到主机名

[root@rhce ~]# vim /etc/hosts
192.168.126.156 www.openlab.com

重启服务

[root@rhce ~]# systemctl restart nginx
[root@rhce ~]# systemctl disable --now firewalld
[root@rhce ~]# setenforce 0

测试

[root@rhce ~]# curl --insecure https://www.openlab.com/money/
money

2、配置DNS的正向解析

基础操作

#装包
[root@localhost ~]# dnf install bind -y

编辑配置文件

#备份文件(根据个人需求,可备份可不备份)
[root@localhost ~]# mv /etc/named.conf{,.bak}
#修改配置文件
[root@localhost ~]# vim /etc/named.conf
options {
        listen-on port 53 { 192.168.126.133; };
        directory       "/var/named";
};
zone "ceshi.com" IN {
                type master;
                file "named.ceshi.com";
};
[root@localhost ~]# vim /var/named/named.ceshi.com
$TTL 1D
@       IN SOA @ admin.baidu.com. ( 0 1D 1H 1W 3H )
        IN NS ns.ceshi.com.
ns      IN A 192.168.126.133
www     IN A 192.168.126.133

重启服务

[root@localhost ~]# systemctl restart named
[root@localhost ~]# systemctl disable firewalld --now
[root@localhost ~]# setenforce 0

测试

[root@localhost ~]# nslookup www.ceshi.com 192.168.126.133
Server:         192.168.126.133
Address:        192.168.126.133#53
 
Name:   www.ceshi.com
Address: 192.168.126.133

  • 16
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晚风替我看朝夕

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值