0

I have a client and I need to execute a curl script on it's server but I get a 404 error.

First I tried the other suggestions I've found on other solutions here (adding headers, cookies...)

After that I asked for a SSH access to be able to check more and that's what I've found:

The only URL that doesn't returns a 404 is the home http://aksentropis.com and it doesn't return the homepage's content it just return <html><body><h1>It works!</h1></body></html>

So I've decided to investigate where this text could be and I've found it on another completely different directories using grep:

./usr/src/httpd-2.4.23/docs/docroot/index.html:1 ./usr/local/apps/apache2/www/htdocs/index.html:1

I've entered those directories and they only contain the index.html file

But, the main folder for public_html is on:

/home/admin/public_html

How can I fix that, or what should I do? I only have a ssh root access.


Update: if I call the url from another server it just works...


Update: I've found the DocumentRoot in the apache was misconfigured.

It was pointing to DocumentRoot "/usr/local/apps/apache2/www/htdocs" and I've updated it to DocumentRoot "/home/admin/www"

Now it loads the php but it doesn't execute it. Why is that?

Pol Rué
  • 301
  • 1
  • 9

1 Answers1

0

It looks to me like the vhost for this site isn't configured to accept your requests. This could either mean from your location, or using the port you're using.

It could be a matter of your source location. A Require, Allow from or Deny from directive inside your vhost can manage access control. Apache Docs: Access Control

Perhaps a proxy (such as a load balancer or firewall) usually intercepts port 443 and 80 traffic and redirects it to other ports, and your vhosts are configured to listen to those other ports. Right now all traffic (from your curl location, most likely localhost) appears to be directed to the default apache site, and paths relative to that index file.

Please check the virtual host configuration for this site. It can usually be found in /etc/apache2/sites-enabled/. If the VirtualHost block for that site contains a colon followed by a number, then that's the port number this block is applied to:

<VirtualHost aksentropis.com:1234>
    DocumentRoot "/home/admin/public_html"
</VirtualHost>

In the above example the server would be configured to listen to port 1234, which means there's usually something that's between external traffic and the server. Apache Docs: Binding to Addresses and Ports

  • Hello Draco, I've just published an update. The 404 only happens on same server so I think it should be somethinf related to the curl configuration. But still I don't know what to do. I've tried your suggestions, also this folder did not exist /etc/apache2/sites-enabled/ the only similar I've found is the nginx /etc/nginx/sites-enabled but the files inside it where all empty. Any clue fo what should I do next? – Pol Rué Aug 09 '17 at 09:01
  • First of all: when curling to your local server, you're probably using localhost or some equivalent. Should you ever edit your vhost to listen for a certain host, you should request that vhost in your curl command. See: https://stackoverflow.com/a/10218482/372643. Secondly, if you haven't told apache how to interpret the php files, it'll just serve them as plain text content. Generally you'd use fpm to do so, nowadays. – Draco Whitefire Nov 13 '17 at 11:55
  • https://wiki.apache.org/httpd/PHP-FPM. TLDR: set a FilesMatch directive for php files to have fpm as a handler. SetHandler "proxy:fcgi://localhost/:9000" – Draco Whitefire Nov 13 '17 at 12:02