#增加用户:
[root@node1 ~]# htpasswd -c /etc/nginx/users song
New password:
Re-type new password:
Adding password for user song
[root@node1 ~]# htpasswd -c /etc/nginx/users tian
New password:
Re-type new password:
Adding password for user tian
[root@localhost ~]# vim /etc/nginx/conf.d/test_httpd.conf
server {
listen 192.168.168.129:80;
root /www/name/openlab/student;
server_name www.openlab.com/student;
location / {
index index.html;
auth_basic on;
auth_basic_user_file /etc/nginx/users;
}
}
访问缴费网站实现数据加密基于https访问
[root@localhost ~]# vim /etc/nginx/conf.d/test_https.conf
server {
listen 192.168.168.129:443 ssl;
root /www/name/openlab/money/;
ssl_certificate /etc/pki/tls/certs/openlab.crt;
ssl_certificate_key /etc/pki/tls/private/openlab.key;
location / {
index index.html;
}
}
[root@localhost ~]# openssl req -utf8 -new -key openlab.key -x509 -days 365 -out openlab.crt
Could not read private key from openlab.key
[root@localhost ~]# openssl genrsa -out /etc/pki/tls/private/openlab.key
[root@localhost ~]# openssl req -utf8 -new -key /etc/pki/tls/private/openlab.key -x509 -days 365 -out /etc/pki/tls/certs/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) [AU]:86
State or Province Name (full name) [Some-State]:xi'an
Locality Name (eg, city) []:shannxi
Organization Name (eg, company) [Internet Widgits Pty Ltd]:open
Organizational Unit Name (eg, section) []:ce
Common Name (e.g. server FQDN or YOUR name) []:local
Email Address []:admin
[root@localhost ~]# systemctl restart nginx