Does IPFS http gateway could run cgi-bin or php-fpm to execute code before rendering?

I was wondering if as apache or nginx is able to do, it would be possible (as a special mode) for go-ipfs to call external processor before rendering /ipns/HASH/file.php link

If I refer to nginx, it could be extra configuration to inform gateway to do that?

    location /ipns/HASH {
        allow all;
        index index.php index.html index.htm;
        location ~ \.php {
                try_files $uri index.php =404;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                include /etc/nginx/fastcgi_params;
                fastcgi_read_timeout 1800;
        error_page 404 = 404.html;
        try_files $uri $uri/ =404;

What do you think? Is it a crazy idea?

1 Like

You could but I’m not sure why. What are you trying to do? The one thing I can think of to use this for is an infrequently accessed compressed file that you need to make available as uncompressed data.

That breaks the contract that the gateway is going to deliver to your browser exactly what you requested.

(apart from opening the gateways to run client-provided code in the server, which is a no go).

If so then many of us should be using a DTN protocol so that our FOG and Edge devices can do the AI heavy lifting of Sensor or Camera data. Common Sensor data is useless for our AI or off-grid Robotics operating system if we are not allowed to process the data locally in a Fog network. How will SigularityNet AGI deal with this?

I have no idea. I am just saying that the IPFS HTTP gateway is not going to run custom server-side code for you. You are allowed to process data locally in whatever way you want though.

1 Like

@hector I understand and agree with your answer. ipfs is a bare swiss knife system and has to stick with it. I can already manage to execute code by accessing ipfs gateway through nginx proxy…

My question was just about appyling a software stack “optimisation”… and it is useless.

You could process your response normally, put it into IPFS and then send the user a 303 or 301 redirect to a gateway. It might be better to describe what you’re trying to do.

Thanks! This is a good idea indeed.