2020年7月

假设访问页面地址为: http://www.abc.com/test.jsp

www.abc.com 域名解析到ip: 192.168.0.1 则curl访问方式为如下:

curl -H "Host:www.abc.com"  "http://192.168.0.1/test.jsp"
  • 实际测试http协议没问题, https协议就像下面一样了
[root@localhost ~]# curl -H "Host:wx.jiayuanshu.net"  "https://139.224.18.242"
curl: (60) Issuer certificate is invalid.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
  • 解决办法, https时使用 --resolve 方法去实现
curl -H "Host:wx.jiayuanshu.net"  "http://139.224.18.242"
curl --resolve 139.224.18.242:443 "https://wx.jiayuanshu.net"

  • Nginx https ssl配置
server {
    listen 443 ssl;   #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
    server_name www.wuloves.com;  #将localhost修改为您证书绑定的域名,例如:www.example.com。
    root /web/www.wuloves.com;
    index index.php index.html index.htm;
    ssl_certificate /key/www.wuloves.com/www.wuloves.com.pem;   #将domain name.pem替换成您证书的文件名。
    ssl_certificate_key /key/www.wuloves.com/www.wuloves.com.key;   #将domain name.key替换成您证书的密钥文件名。
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;  #使用此加密套件。
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   #使用该协议进行配置。
    ssl_prefer_server_ciphers on; 

#    location / {
#        try_files $uri $uri/ /index.php?$query_string;
#    }
    # 将blog目录下的路由重写到blog/index.php

    location /blog/ {
        if (!-e $request_filename) {
            rewrite ^/ /blog/index.php last;
        }
    }

    location ~ \.php {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_split_path_info  ^(.+\.php)(/.*)$;
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        include        fastcgi.conf;
        if (!-e $request_filename) {
            rewrite ^/ /blog/index.php last;
        }
    }
        access_log /web/logs/www.wuloves.com.success.ssl.log;
        error_log  /web/logs/www.wuloves.com.error.ssl.log;
} 
  • Nginx 强制https访问
server {
    listen       80;
    server_name  www.wuloves.com;
    rewrite ^(.*)$  https://$host$1 permanent;  
    access_log /dev/null;
    error_log  /dev/null;
}

linux下mysql8.0重置密码的方法
过程是先设置无密码登录, 把root的密码设为空字符, 在取消无密码登录, 再登录root, 再执行重置密码动作
无密码登录mysql
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables";
systemctl restart mysqld
mysql 回车即可
update mysql.user set authentication_string=''  where User='root';
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abc123456!';