the API return 404 (or 501/302 when using /api/index.php?)
-
I’m sorry for the double-posting, but after submitting my issue on github (https://github.com/FOGProject/fogproject/issues/263) I realized that it could have been a technical issue (even though, the installation of both, system + FOG is brand new).
Basically, the API doesn’t seems to works correctly, the log are on the github, for for better reading/following, here is a copy/paste of my issue :
Hi there,
I’m currently unable to use the API as I constantly got either a 404 or 501/302 (using for instance, this command) :
$ curl -H "fog-api-token: MjUwYjkxNGU4YTJkNjM3MDliNmVlZDFjZGE5YjcwNjg2N2Y1ZWE1NjMxMzFkZTk4Y2ZhOWZjNGJjZDUyZGIxNTljODg0NDhiM2RlODBmMzc5ZWFkMTkxxxxx1NDU5OTZhMzIwODJmYThiNWI0MzhhYjkwMDZhNzQ1MTFiNjg" -H "fog-user-token: NTQ5MWJiMjgxNmI5OTcyZDM5OTMzMWJlZjlkZWM4Y2M2MDg0ZTI5MTQ5MGZlYzdkNmYzY2NjNTc1OGE1ZGE3ODY4NDlkOWU4NjFiMzdmOTU5MDxxxN2NjNDQxYjhlMWI3MjYxZDMxZmRkZmNkY2M1Mjk4ZGNmZGUzMzNiNWY" -X GET http://192.168.6.128/fog/system/info <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /fog/system/info was not found on this server.</p> <hr> <address>Apache/2.4.34 (Ubuntu) Server at 192.168.6.128 Port 80</address> </body></html>
from apache “acces.log” ;
"GET /fog/system/info HTTP/1.1" 404 453 "-" "curl/7.58.0"
Using /api/index.php?system/info gave me a 501 :
$ curl -H "fog-api-token: MjUwYjkxNGU4YTJkNjM3MDliNmVlZDFjZGE5YjcwNjg2N2Y1ZWE1NjMxMzFkZTk4Y2ZhOWZjNGJjZDUyZGIxNTljODg0NDhiM2RlODBmMzc5ZWFkMTkxxxxx1NDU5OTZhMzIwODJmYThiNWI0MzhhYjkwMDZhNzQ1MTFiNjg" -H "fog-user-token: NTQ5MWJiMjgxNmI5OTcyZDM5OTMzMWJlZjlkZWM4Y2M2MDg0ZTI5MTQ5MGZlYzdkNmYzY2NjNTc1OGE1ZGE3ODY4NDlkOWU4NjFiMzdmOTU5MDxxxN2NjNDQxYjhlMWI3MjYxZDMxZmRkZmNkY2M1Mjk4ZGNmZGUzMzNiNWY" -X GET http://192.168.6.128/fog/api/index.php?system/info
Related access.log entry:
"GET /fog/api/index.php?system/info HTTP/1.1" 501 678 "-" "curl/7.58.0"
FYI; here is my (untouched) /etc/apache2/sites-enabled/001-fog.conf:
<VirtualHost *:80> <FilesMatch "\.php$"> SetHandler "proxy:fcgi://127.0.0.1:9000/" </FilesMatch> KeepAlive Off ServerName 192.168.2.1 DocumentRoot /var/www/ <Directory /var/www/fog/> DirectoryIndex index.php index.html index.htm </Directory> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d RewriteRule ^/fog/(.*)$ /fog/api/index.php [QSA,L] </VirtualHost>
Could you please let me know what else should I check as there is no logs on /opt/fog/log/* related to the API.
-
Please check fog settings for fog_api_enabled
I believe it is defaulted to disabled to ensure some small level of safety, as the default user/password is well known.
-
Hi @Tom-Elliott,
As far as I can see, everything looks normal/Activated :
-
Hi @Tom-Elliott ,
I tried to disable / enable again : No luck
I tried to reset both token : No luck.Any idea ?
-
@Nono Sorry for the very long delay. Took me a while to find the time to look into this and figure it out. Seems like the default site apache config is somehow overwriting our 001-fog.conf and therefore the rewrite rules don’t kick in. Not sure if this is just on Ubuntu. Don’t have the time to try other distros as well but for now I assume this is specific for Ubuntu. Run this to fix the issue for now:
a2dissite 000-default.conf service apache restart
-
@Sebastian-Roth said in the API return 404 (or 501/302 when using /api/index.php?):
@Nono Sorry for the very long delay. Took me a while to find the time to look into this and figure it out. Seems like the default site apache config is somehow overwriting our 001-fog.conf and therefore the rewrite rules don’t kick in. Not sure if this is just on Ubuntu. Don’t have the time to try other distros as well but for now I assume this is specific for Ubuntu. Run this to fix the issue for now:
a2dissite 000-default.conf service apache2 restart
Thanks @Sebastian-Roth,
Expect the “apache2” instead of “apache”, it works much better !
I’m going to update the github case as well. -