Curl –-limit-rate 2000B Using a proxy to connect. Very handy if you are working on the DMZ server where you need to connect to the external world using a proxy. Curl -proxy yourproxy:port Test URL with injecting header. You can use curl by inserting a header with your data to test or troubleshoot the. The curl command transfers data to or from a network server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE). It is designed to work without user interaction, so it is ideal for use in a shell script.
today I am trying to make a curl call to somesite which is listening to port 8080. However, calls like this get sent to port 80 and not 8080 instead:
am i missing something here?
Just a note, I’ve had this issue before because the web host I was using was blocking outbound ports aside from the standard 80 and 443 (HTTPS). So you might want to ask them or do general tests. In fact, some hosts often even block outbound on port 80 for security.
Have you tried to SSH into the server that runs this and verify the iptables rules, and/or attempt to connect via telnet to the target server?
sh
telnet somesite.tld 8080
If nothing else, it will help troubleshoot your problem and eliminate network issues.
First check that you’re able to connect using something other than PHP’s horrible Curl syntax:
- Chrome’s Postman is easy to use if you’re on your local machine,
else look at using (for linux users) Os x free download.
- curl somesite:8080
- wget -qO- somesite:8080
Once you’ve established you can connect, then you can go about the horrible business of using PHP Curl. There are wrappers, but they’re flaky that I’ve found.
Both Curl, Wget or similar can be very easily configured to use GET and POST methods. It’s not advisible, but for more than one complicated operation using Curl I’ve simply given up trying to configure PHP’s library correctly and simply dropped to the command line.
THERE ARE SECURITY IMPLICATIONS. You need to take great care to ensure that anything you give it, particularly if it’s from a form or an external source, is appropriately escaped.
Your web server is misconfigured. The code you provided works for me.
Also, your code can be simpler. Just put the URI into the init call and drop the CURLOPT_PORT
and CURLOPT_URL
lines:
$ch = curl_init('http://somesite.tld:8080');
Are you sure that the server you intent to join isn’t firewalled? And that Selinux is disabled?
Maby you can use
–local-port [-num]
Set a preferred number or range of local port numbers to use for the connection(s). Note that port numbers by nature are a scarce resource that will be busy at times so setting this range to something too narrow might cause unnecessary connection setup failures. (Added in 7.15.2)
Source: http://curl.haxx.se/docs/manpage.html#–ftp-pasv
Simple CURL GET
request: (Also added json/headers if required, to make your life easier in need)
Example POST
request:
Charset is not a required HTTP header and so are the others, the important one is Content-Type.
For the examples I used JSON MIME type, You may use whatever you want, take a look at the link:
http://en.wikipedia.org/wiki/Internet_media_type
Curl Port 8080
Make sure that the php_curl.dll
extension is enabled on your php, and also that the ports are open on the target serve.
Hope this helps.
Curl Port 25
Curl Command Line Options
Tags: curl, phpphp, url