How to configure nginx in Docker on alpine with perl to run CGI files?

Viewed 523

I try to start a project where I need to configure Docker to run Perl CGI files with nginx.

Now I have this docker-compose.yml file:

version: "3"
services:
  httpd:
    image: 'nginx:stable-alpine-perl'
    ports:
      - '80:80'
    volumes:
      - ./:/var/www/html
      - ./.docker-config/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      # - perl
      - mysql
    command: [nginx-debug, '-g', 'daemon off;']

  mysql:
    image: mysql:5.7
    env_file:
      - ./.docker-config/mysql/mysql.env
    ports:
      - '33060:3306'

The nginx.conf is this:

server {
    listen 80;
    server_name localhost;
    access_log /var/log/nginx/access.log;
    index index.cgi index.html index.htm;
    root /var/www/html;

    location / {
        autoindex on;
    }

    location ~ \.cgi {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
    }
}

The index.html file works like a charm, but the index.cgi say 502 Bad Gateway.

UPDATE

I see this in the nginx' error log:

"GET /index.cgi HTTP/1.1" 502 559 "-" "Mozilla/5.0..."
[crit] 24#24: *9 connect() to unix:/var/run/fcgiwrap.socket
    failed (2: No such file or directory) while connecting to
    upstream, client: 172.27.0.1, server: ....a_domain_...,
    request: "GET /index.cgi HTTP/1.1", upstream:
    "fastcgi://unix:/var/run/fcgiwrap.socket:",
    host: "...a_domain..."

What I miss?

0 Answers
Related