Linux中通过curl命令绑定host访问网页的方法
假设访问页面地址为: 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"