fastcgi-mono-server4 and nginx with docker fastcgi-mono-server4 and nginx with docker nginx nginx

fastcgi-mono-server4 and nginx with docker


The fastcgi-mono-server4 has a limitation on docker container with the listening address when you use the parameter

  • /socket=tcp:9000 only listen in localhost
  • /socket=tcp:0.0.0.0:9000 only listen in localhost, weird but true

to fix the fastcgi-mono-server4 behavior, you have to use the docker container IP address in socket parameter

  • /socket=tcp:IPContainer:9000
  • /socket=tcp:$(ip -4 addr show eth0| grep -Po 'inet \K[\d.]+'):9000

you need to fix the command inside the Docker container

fastcgi-mono-server4 /applications=/:/var/www/websharper/ /socket=tcp:$(ip -4 addr show eth0| grep -Po 'inet \K[\d.]+'):9000

This is an example the Dockerfile fixed

FROM mono:latestRUN apt-get updateRUN apt-get install -y mono-fastcgi-server4RUN rm -rf /var/lib/apt/lists/* /tmp/*RUN echo "#!/bin/sh\nfastcgi-mono-server4 /applications=/:/var/www/websharper/ /socket=tcp:\$(ip -4 addr show eth0| grep -Po 'inet \K[\d.]+'):9000" > /opt/mono-fastcgiRUN chmod +x /opt/mono-fastcgiEXPOSE 9000CMD [ "/opt/mono-fastcgi" ]