I have the following Dockerfile:
FROM nginx
RUN apt-get update
RUN apt-get install python3 python3-pip fcgiwrap -y
the docker-compose.yml:
version: '3.3'
services:
nginx:
build: ./data-nginx/.
container_name: nginx
restart: always
ports:
- "80:80"
- "443:443"
networks:
- webserver
volumes:
- ./data-nginx/conf.d/:/etc/nginx/conf.d/
- ./data-nginx/fastcgi.conf:/etc/nginx/fastcgi.conf
- ./data-nginx/proxy.conf:/etc/nginx/proxy.conf
- ./data-nginx/mime.types:/etc/nginx/mime.types
- ./data-nginx/fcgiwrap.conf:/etc/nginx/fcgiwrap.conf
- ./www:/var/www
The dafault.conf of nginx:
server {
listen 80;
server_name _;
root /var/www;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
include fcgiwrap.conf;
}
and fcgiwrap.conf:
location /cgi-bin/ {
gzip off;
root /var/www;
fastcgi_pass unix:/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
}
in /var/www/cgi-bin/ I have test.py:
#!/usr/bin/python3
print("Test")
When I now go to http://localhost/cgi-bin/test.py
I get:
[error] 31#31: *1 connect() to unix:/run/fcgiwrap.socket failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: _, request: "GET /cgi-bin/test.py HTTP/1.1", upstream: "fastcgi://unix:/run/fcgiwrap.socket:", host: "localhost"
What I want to accomplish, is basically to run a python on a host (local) from a website by pressing a button.