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