Jorge Carvalho Posted March 23, 2023 Share Posted March 23, 2023 Hi, I am using an internal develop server running Prestashop 1.7.8.6 and php 7.2. When I dont use php-fpm I can get a blank XML for categories for example. define('DEBUG', true); define('PS_SHOP_PATH', '192.168.0.18'); define('PS_WS_AUTH_KEY', '7B52FTR2CY7LV8A8JXMRS8DNVYAWPA17'); require_once('PSWebServiceLibrary.php'); // Here we use the WebService to get the schema of "customers" resource try { $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'categories'); if (isset($_GET['Create'])) { $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/categories?schema=blank')); print_r($xml);die(); } else { die("nope!"); $xml = $webService->get($opt); } but when I go to 000-default.conf and change to FPM I got 401 HTTP REQUEST HEADER GET /api/categories?schema=blank HTTP/1.1 Host: 192.168.0.18 Authorization: Basic N0I1MkZUUjJDWTdMVjhBOEpYTVJTOEROVllBV1BBMTc6 Accept: */* HTTP RESPONSE HEADER HTTP/1.1 401 Unauthorized Date: Thu, 23 Mar 2023 10:35:44 GMT Server: Apache/2.4.41 (Ubuntu) WWW-Authenticate: Basic realm="Welcome to PrestaShop Webservice, please enter the authentication key as the login. No password required." Set-Cookie: PrestaShop-b495097bf03a2b246a17e22e09a4dd34=def5020074ae8b24cac8a0f74007fe087f73a859db4d3fc20f2c5546d818a61e82bc72445494c46ad75ee70856f94c7455a7bd116fc6af38283bba65d7cddd619b9f392383f5248ae3b76fde727e760f9be8139bb41ddb06cdb7caee496877bd0deea19e75813141873dfb46de7f6bcb0e0ee22198b64c09deb43606eb814d33a98145e40fba2fd2f3b15269ef115f884869955cb4cd83d64d1fe70b1230c5498a9322cc4ef56f09bc80bd83088a09f1d8934f727d212a114d01a56b28ba983b21604c9381da648b6cbb0461a0dbcee04b76d9c1d6488356fb; expires=Wed, 12-Apr-2023 10:35:44 GMT; Max-Age=1728000; path=/; domain=; SameSite=Lax; HttpOnly Transfer-Encoding: chunked Content-Type: text/html; charset=utf-8 RETURN HTTP BODY 401 Unauthorized Other error HTTP XML response is not parsable: array ( 0 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 4, 'column' => 1, 'message' => 'Start tag expected, \'<\' not found ', 'file' => '', 'line' => 1, )), ) How my conf file looks # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html <FilesMatch \.php$> # SetHandler proxy:fcgi://127.0.0.1:9000 SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost" </FilesMatch> <Directory /var/www/html> AllowOverride All Options +Indexes Require all granted </Directory> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> Can someone point me what is wrong with this configuration? Many thanks! Jorge Link to comment Share on other sites More sharing options...
Jorge Carvalho Posted March 23, 2023 Author Share Posted March 23, 2023 found solution: Just add SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 to your vhost file, in my case 000-default.conf in /etc/apache2/sites-enabled Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now