Apache response 401 while trying to connect to API

adi5497

Verified User
Joined
Jan 14, 2020
Messages
21
Hello, I have problem with webservice (API) of PrestaShop. I'm Looking for the reason beacuse previously on shared hosting everything was working. When I'm trying to connect to webservice (API), I'm getting error 401. I have checked logs and i can see:

access_log:
Code:
IP - - [15/Feb/2020:10:22:05 +0000] "-" 408 3785 "-" "-"
domain.com.log
Code:
IP - - [15/Feb/2020:12:20:38 +0000] "GET /api/ HTTP/1.0" 301 475 "-" "-"
IP - - [15/Feb/2020:12:20:38 +0000] "GET /api/ HTTP/1.0" 401 4608 "-" "-"
Also, I have checked Symfony Profiler in PrestaShop. I saw Server Parameters and there is:
Code:
CONTEXT_DOCUMENT_ROOT    "/home/admin/domains/domain.com/private_html"
DOCUMENT_ROOT    "/home/admin/domains/domain.com/private_html"
I think there should be public_html instead of private_html, so I checked httpd.conf file and in <VirtualHost IP:443 > section there was private_html in DocumentRoot so I did this for cutomization:
Code:
|?DOCROOT=/home/admin/domains/domain.com/public_html|
and httpd.conf has been changed in <VirtualHost IP:443 > section from private_html to public_html. So I have checked Symfony Profiler in PrestaShop and Server Parameters still said:
Code:
CONTEXT_DOCUMENT_ROOT    "/home/admin/domains/domain.com/private_html"
DOCUMENT_ROOT    "/home/admin/domains/domain.com/private_html"

I'm using Apache + PHP-FPM (PHP 7.0). I'm out of ideas what to do next because i thought it could be a apache+nginx fault, but I have a fresh install now and the same problem.

EDIT: Now Symfony Profiler in PrestaShop shows public_html but still have error 401.
EDIT2: For a test, I have installed VestaCP to test if problem with connection to API will still remains, but it's not. APi working without any error. Where could be a problem with config of DirectAdmin? Or Apache?
 
Last edited:

adi5497

Verified User
Joined
Jan 14, 2020
Messages
21
I have found a reason why PrestaShop API is not working. The reason is a SSL and http to https redirection. Prestashop webservices works via http, not https. If I set to use http-https redirect, it starts to show error 401 Unauthorized. There is any way to use Lets Encrypted SSL and let webservice working via http?
 
Top