October 25, 2024
Chicago 12, Melborne City, USA
PHP

Php with Nginx issue in docker on Azure


I am trying to deploy docker image as Azure Web App.
Docker image is working localy but it is not in Azure.
I’ve been trying to figure this out for over 2 days now with no luck, so any adivice / idea is welcome.

I am getting this error:

2024-10-25T14:15:41.488521354Z nginx: [emerg] host not found in upstream "php" in /etc/nginx/sites-enabled/default:42 2024-10-25T14:15:41.491011661Z 2024-10-25 16:15:41,490 WARN exited: nginx (exit status 1; not expected) 2024-10-25T14:15:42.493193058Z 2024-10-25 16:15:42,493 INFO gave up: nginx entered FATAL state, too many start retries too quickly

Config files:

Compose:

services: php: 
build: 
    context: docker/php-fpm 
    args: 
    - TZ=${TZ} 
    - PUID=${PUID} 
    - GUID=${GUID} 
    - APP_ENV=${APP_ENV} 
    env_file: - .env
    ports: - 8080:80    
volumes:
        - ./:/var/www/symfony
        - ./var/nginx/:/var/log/nginx`

nginx.config (which is copied to /etc/nginx/sites-available/default)

map_hash_bucket_size 128;
server { 
    root /var/www/symfony/web; client_max_body_size 50M;
    location ~ ^/app\.php(/|$) {
    add_header 'Access-Control-Allow-Origin' '*';
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
}

sendfile off;
www.conf[www]
user = www-datagroup = www-data
; Listen on a socket or portlisten = 0.0.0.0:9000
; Set the PHP-FPM process managerpm = dynamicpm.max_children = 5pm.start_servers = 2pm.min_spare_servers = 1pm.max_spare_servers = 3
; Set the path to your php.iniphp_value[error_log] = /var/log/php-fpm/error.logphp_value[memory_limit] = 128M

I’ve been tempering with the config files, ports in both azure and compose file.
As I understand it the nginx is unable to comunicate with php service on port 9000 but I have no idea why, especialy since it is working on localhost just fine (using docker desktop)



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video