基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
网站需求:
1.基于域名www.openlab.com可以访问网站内容为 welcome to openlab!!!
2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于www.openlab.com/student 网站访问学生信息,www.openlab.com/data网站访问教学资料
www.openlab.com/money网站访问缴费网站。
3.要求 (1)访问该网站http请求都通过https响应。
(2)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
配置.conf文件
vim /etc/nginx/nginx.conf
server {
listen 80;
server_name www.openlab.com;
root /www/openlab;
}
配置映射关系
vim /etc/hosts
192.168.155.131 www.openlab.com
关闭防火墙
创建子网站www.openlab.com www.openlab.com/data www.openlab.com/student www.openlab.com/money
配置文件
配置data
vim /etc/nginx/nginx.conf
location /data {
alias /www/openlab/data;
index index.html index.htm;
}
配置student
vim /etc/nginx/nginx.conf
location /student {
alias /www/openlab/student;
index index.html index.htm;
auth_basic "Please input password";
auth_basic_user_file /www/openlab/student/passwd;
}
学生信息网站只有song和tian两人可以访问
useradd song
passwd song
useradd tian
passwd tian
htpasswd -c /www/openlab/student/passwd song
htpasswd /www/openlab/student/passwd tian
配置money
vim /etc/nginx/nginx.conf
server {
listen 443 ssl http2;
server_name www.openlab.com;
location /money { #子目录
alias /www/openlab/money;
index index.html index.htm;
}
ssl_certificate "/www/openlab/money/money.crt";
ssl_certificate_key "/www/openlab/money/money.key.org";
}
私钥
openssl genrsa -aes128 2048 > /www/openlab/money/money.key
证书
openssl req -utf8 -new -key /www/openlab/money/money.key -x509 -days 365 -out /www/openlab/money/money.crt
去除私钥
cp /www/openlab/money/money.key /www/openlab/money/money.key.org
openssl rsa -in /www/openlab/money/money.key -out /www/openlab/money/money.key.org
测试
