0

We have a cPanel host running on centos that has got me stumped. I am trying to use curl from the command line to trigger a specific web page. However I keep getting 404 errors for the specific page whereas the main page works fine.

curl http://example.com

This works fine.

curl http://example.com/dev/buil?flush=all

This returns a 404 every time. I can access this exact page from a web browser and indeed running this command from another remote Linux box works fine. I have run a packet capture on the firewall that it sits behind and can find no blocked packets, only DNS requests for example.com.

I am really stumped as to where to look next as I was certain I was going to find some kind of rule conflict on the firewall blocking a port that curl needed but alas I have found nothing.

  • What does curl -v ... say ? – user9517 Jul 24 '13 at 13:27
  • When you visit http://example.com/dev/buil?flush=all in your browser, is your browser conveniently redirecting you to http://WWW.example.com/dev/buil?flush=all ? Perhaps it is, and your Apache virtual host is not configured with an example.com ServerAlias (only www.example.com). – loopforever Jul 24 '13 at 13:28

1 Answers1

0

A 404 error has nothing to do with a firewall. 404 represents "Page not found" and is generated by the web-server itself. It is not uncommon for web-servers to be configured to support "virtual-hosting" in which, different websites are offered on different network interfaces.

In this case, this could mean that you have a different virtual host on 127.0.0.1 (the loopback interface) than the wan interface. You may need to adjust your hosts file to point that "hostname" to the wan interface, instead of the "localhost" interface.

TheCompWiz
  • 7,349
  • 16
  • 23
  • He browsed to the same host, so virtualhosts don't matter. – Nathan C Jul 24 '13 at 13:32
  • Same host does not mean same interface. It is very likely that he is getting the default site on 127.0.0.1 instead of the host on the expected interface. – TheCompWiz Jul 24 '13 at 13:39
  • harsh down vote. Especially as you are bang on. Added the WAN IP and name to the hosts file and now it starts resolving and processing correctly. Thank you very much for the suggestion. –  Jul 24 '13 at 13:40