0

I have a server listening on http://0.0.0.0:8000, however this is living in an Amazon instance.

How can I make an HTTP POST request from an external computer (using curl)? That is, I would like to use the server listening as an API. This is different from other cases because I would like to do it over ssh.

  • 1
    Thanks for the help Attie, yes that's what I meant – anon Oct 17 '18 at 14:08
  • "listening on 0.0.0.0:8000" means "listening on all interfaces" - so can you communicate with it on it's public IP? (the same you would use for SSH) – Attie Oct 17 '18 at 14:08
  • Yes I think so Attie, when I start the server it just says: no port specified, defaulting to port 8000 that lives in the ec2 instance. I would like to do the curl -XPOST from an "external machine" – anon Oct 17 '18 at 14:10
  • I presume you are able to use SSH? Have you tried using curl with the same IP you used for SSH? – Attie Oct 17 '18 at 14:11
  • No, could you provide an example attie? – anon Oct 17 '18 at 14:12
0

If you want to run curl on the EC2 instance, and tunnel the output via ssh, then try the following:

ssh ${USERNAME}@${EC2_INSTANCE_IP} curl -s http://localhost:8000/

You should see the result directly on the terminal (-s will inhibit curl's output).

You can run any command like this, there's nothing special for curl.

If this works, then you can alter the curl parameters to use -X POST and/or -d, along with the correct endpoint.


Please remember though, that 0.0.0.0 is a "special" address that actually means "listening on all interfaces"... So unless you configure the inbound rules correctly, anyone can still do curl http://${EC2_INSTANCE_IP}:8000/ and hit your server.

  • Do you have a reference on how to configure this on the amazon instance? I got a Failed to connect to the instance, timed out – anon Oct 17 '18 at 14:47
  • You might like to ask another question, specifically around inbound rules for EC2... get the basic SSH working first, and then come back and try to "use curl over SSH" afterwards. – Attie Oct 17 '18 at 15:45
  • This link might help: Authorizing Inbound Traffic for Your Linux Instances – Attie Oct 17 '18 at 15:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.