使用 https 将 bash 卷曲到同一台服务器
Curl bash to same server with https
我已通过 cron 任务从同一台服务器向 url 发出请求。过去我用下一个 bash 脚本来做到这一点:
#!/bin/sh
curl "http://www.mydomain.es/myfolder/importTwitter" >> /var/log/mydomain/import_twitter.log
我将网站迁移到 https,但 curl 命令失败并返回下一个错误:
* About to connect() to www.mydomain.es port 443 (#0)
* Trying xxx.xxx.xxx.xxx...
* Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
我尝试将下一个参数添加到 curl 命令,但得到了同样的错误:
--cacert -> specify ssl ca root certificate
--cert -> specify ssl pem certificate
--location -> using the http url and force to follow redirects
--insecure -> allows insecure curl connections
最后我也尝试从另一个主机发出请求并且工作正常,但我从同一台服务器发出请求。
服务器有 Debian 3.2.65-1+deb7u2 x86_64
Curl版本:
curl 7.26.0 (x86_64-pc-linux-gnu) libcurl/7.26.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.25 libssh2/1.4.2 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: Debug GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
* Connection refused
你的问题就在那里。早在任何带有加密的东西开始之前,你的服务器根本不允许来自你的主机的连接。
确保您的服务器配置正确并且没有防火墙阻止到端口 443 的环回连接。
我已通过 cron 任务从同一台服务器向 url 发出请求。过去我用下一个 bash 脚本来做到这一点:
#!/bin/sh
curl "http://www.mydomain.es/myfolder/importTwitter" >> /var/log/mydomain/import_twitter.log
我将网站迁移到 https,但 curl 命令失败并返回下一个错误:
* About to connect() to www.mydomain.es port 443 (#0)
* Trying xxx.xxx.xxx.xxx...
* Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
我尝试将下一个参数添加到 curl 命令,但得到了同样的错误:
--cacert -> specify ssl ca root certificate
--cert -> specify ssl pem certificate
--location -> using the http url and force to follow redirects
--insecure -> allows insecure curl connections
最后我也尝试从另一个主机发出请求并且工作正常,但我从同一台服务器发出请求。
服务器有 Debian 3.2.65-1+deb7u2 x86_64
Curl版本:
curl 7.26.0 (x86_64-pc-linux-gnu) libcurl/7.26.0 OpenSSL/1.0.1e zlib/1.2.7 libidn/1.25 libssh2/1.4.2 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: Debug GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
* Connection refused
你的问题就在那里。早在任何带有加密的东西开始之前,你的服务器根本不允许来自你的主机的连接。
确保您的服务器配置正确并且没有防火墙阻止到端口 443 的环回连接。