Sigo Serving CGI Scripts With Nginx On Debian Squeeze/Ubuntu 11.04 - Page 3 - Page 3
FROM nginx:latest
RUN apt-get update
RUN apt-get install -y fcgiwrap
RUN update-rc.d fcgiwrap defaults 20
RUN sed -i 's/www-data/nginx/g' /etc/init.d/fcgiwrap
COPY default.conf /etc/nginx/conf.d
COPY hello.cgi /usr/share/nginx/cgi-bin/hello.cgi
RUN chmod +x /usr/share/nginx/cgi-bin/hello.cgi
EXPOSE 80
CMD /etc/init.d/fcgiwrap start && nginx -g 'daemon off;'
y el archivo default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /cgi-bin/ {
# Disable gzip (it makes scripts feel slower since they have to complete
# before getting gzipped)
gzip off;
# Set the root to /usr/share/nginx
# (inside this location this means that we are
# giving access to the files under /usr/share/nginx/cgi-bin)
root /usr/share/nginx;
# Fastcgi socket
fastcgi_pass unix:/var/run/fcgiwrap.socket;
# Fastcgi parameters, include the standard ones
include /etc/nginx/fastcgi_params;
# Adjust non standard parameters (SCRIPT_FILENAME)
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
y un cgi de prueba:
#!/bin/bash
# Construir los encabezados HTTP
echo "Content-type: text/html"
echo ""
# Y ahora el BODY del mensaje HTTP
echo "<html><head><title>Hello World!! </title></head>";
echo "<body><h1>Hello world</h1></body></html>";
worker:
#!/bin/bash
BLOCK="Hola caracola"
NONCE=$1
RESULT=999
while echo -n "$RESULT" | grep ^000 -q -v
do
RESULT=$(echo $BLOCK:$NONCE | shasum -a 512)
NONCE=$(expr $NONCE + 1)
done
echo Hash: $RESULT
echo Nonce: $NONCE
.
โโโ bashwebapp
โ โโโ app
โ โ โโโ hello.cgi
โ โ โโโ mine.cgi
โ โ โโโ worker.sh
โ โโโ default.conf
โ โโโ Dockerfile
โโโ docker-compose.yml
#!/bin/bash
# Construir los encabezados HTTP
echo "Content-type: application/json"
echo ""
# Obtener de la QUERY el bloque a minar
# ?bloque=bloqueaminar
# Minado
. ./worker.sh
BLOQUE=$(echo $QUERY_STRING | cut -d= -f2)
RESULT=$(minar $BLOQUE)
# Devolver respuesta en el BODY del mensaje JSON
cat << FIN
{
"bloque": "$BLOQUE",
"hash": "$RESULT"
}
FIN
function minar {
BLOCK=$1
NONCE=$RANDOM
RESULT=999
while echo -n "$RESULT" | grep ^0000 -q -v
do
RESULT=$(echo $BLOCK:$NONCE | sha512sum )
NONCE=$(expr $NONCE + 1)
done
echo $(echo $RESULT | cut -d'-' -f1)
}
:bulb: This template helps you prepare for and collect important ideas from product meetings.
Jan 27, 2025The goal is to design the processor scheduler for the new VenanciOS operating system. For this purpose, a preemptive algorithm has been devised with dynamic priorities between 0 and 31, where low numbers indicate low priority and high numbers indicate high priority. Processes always start with a fixed priority of value 15. If their quantum is exhausted, their priority decreases by one unit (at least to the value 0) and, if the process does not exhaust and is ejected, it remains with the same priority. If the process goes to sleep waiting for a resource, when it wakes up it increases its priority (boosting), depending on the type of resource, according to the following table:
Dec 9, 2024Creamos una imagen nueva a partir de python:latest.
Dec 9, 2024In the downloader practice we are told to download a big file using several processes working each on a different range of this big file. The file used as an example is hosted in a machine which IP is not reachable from Eduroam network. To overcome this, it is really easy to spin a webserver locally and use it to test our practice implementation.
Dec 2, 2024or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up