php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -


my wordpress installation on azure app service on linux using custom docker container has slow response times. pages take around 20-40 seconds load.

i have troubleshooting plugin installed indicates problem "curl error 28: resolving timed out after n milliseconds" when making requests following urls

curl errors

curl works fine on scm-site command line. example works ok.

curl -x post http://api.wordpress.org/core/version-check/1.7/ 

edit if ssh container , run php code, works fine.

<?php  $url = 'http://api.wordpress.org/core/version-check/1.7/';  $fields = array(     'version' => urlencode('4.8.1'),     'php' => urlencode('7.1.8'),     'locale' => urlencode('fi'),     'mysql' => urlencode('5.6.26.0'),     'local_package' => urlencode('fi'),     'blogs' => urlencode('1'),     'users' => urlencode('4'),     'multisite_enabled' => urlencode('0'),     'initial_db_version' => urlencode('26691') );  foreach($fields $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&');  $ch = curl_init();  curl_setopt($ch,curlopt_url, $url); curl_setopt($ch,curlopt_post, true); curl_setopt($ch,curlopt_postfields, $fields_string);  curl_exec($ch);  curl_close($ch); 

it returns following.

root@71c3bba3a35e:/home/site/wwwroot# php curl.php {"offers":[{"response":"upgrade","download":"http:\/\/downloads.wordpress.org\/release\/wordpress-4.8.1.zip","locale":"en_us","packages":{"full":"http:\/\/downloads.wordpress.org\/release\/wordpres s-4.8.1.zip","no_content":"http:\/\/downloads.wordpress.org\/release\/wordpress-4.8.1-no-content.zip","new_bundled":"http:\/\/downloads.wordpress.org\/release\/wordpress-4.8.1-new-bundled.zip","par tial":false,"rollback":false},"current":"4.8.1","version":"4.8.1","php_version":"5.2.4","mysql_version":"5.0","new_bundled":"4.7","partial_version":false}],"translations":[]} 

my docker image uses php:7.1.8-apache.

here dockerfile.

from php:7.1.8-apache expose 80 443 2222  run apt-get update -y && apt-get install -y --no-install-recommends \     ssl-cert \     ca-certificates \     apt-utils \     vim \     curl \     mysql-client \     openssh-server \     libmcrypt-dev \     libcurl4-gnutls-dev \     libicu-dev \ && docker-php-ext-install -j$(nproc) iconv \ mcrypt \ mysqli \ json \ mbstring \ curl \ intl \ && echo "root:docker!" | chpasswd \ && ln -s /home/logfiles /var/log/apache2  env apache_confdir=/etc/apache2 \ apache_envvars=/etc/apache2/envvars \ apache_lock_dir=/var/lock/apache2 \ apache_log_dir=/var/log/apache2 \ apache_run_dir=/var/run/apache2 \ apache_pid_file=/var/run/apache2/apache2.pid \ apache_run_user=www-data \ apache_run_group=www-data  workdir /usr/local copy config/wprun.sh config/wp-config.php /usr/local/ copy config/sshd_config /etc/ssh/ copy config/php.ini /usr/local/etc/php/   run chmod 755 wprun.sh && \ rm -r /var/www/html && \ a2enmod rewrite && \ a2enmod expires && \ a2enmod include && \ sed -i "s@/var/www@/home/site/wwwroot@" /etc/apache2/sites-enabled/000-default.conf && \ sed -i "s@/var/www@/home/site/wwwroot@" /etc/apache2/apache2.conf  cmd ["/bin/bash","wprun.sh"] 

edit 2 github issue seems similar. there suggestion use opendns resolvers. dns issue? if so, how work docker , azure?

edit 3 seems dns issue. resolv.conf file in azure.

search reddog.microsoft.com nameserver 127.0.0.11 options timeout:1 attempts:5 ndots:0 

when change nameserver 8.8.8.8, pages load in 1 2 seconds. curl errors go away.

if understand correctly, docker mounts host machine's resolv.conf file , dns settings should set docker run command options. it's not recommended change these files directly.

the exact details of how docker manages dns configurations inside container can change 1 docker version next. should not assume way files such /etc/hosts, /etc/resolv.conf managed inside containers , leave files alone , use following docker options instead.

however, doesn't seem possible set docker run parameters in azure.

the scm-site command line curl works on host machine of azure webapps linux, not inside docker container.

there issue curl fails inside container on https connection on github moby/moby, similar yours. according this, think need set --tlsv1 option via php method curl_setopt($curl, curlopt_ssl_cipher_list, 'tlsv1'); curl call inside docker container of azure webapp linux.

hope helps.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -