################################################################################ # httpd-proxy-mdns # Building : # 1. Place this file to working directory. # 2. Run following command. # Usage : docker build -t [:] \ # --build-arg PROXY_ALLOW_FROM=/ \ # [--build-arg PROXY_PORT=] [--build-arg PROXY_DOMAIN=] \ # [--build-arg PROXY_URL=] -f . # * / : Apache configuration for "Allow from" of . # Running : # docker run --name= --restart=always --network=host \ # -it [:] # Note : # * Allow firewall to tcp . # * If run this container as service, do following # i) Execute "docker create --name= --restart=always # --network=host httpd-proxy-mdns:" # ii) Create unit file as followig # ---------------------------------------------------------------------- # [Unit] # Description=Proxy container serivice with mdns # Wants=syslog.service # After=network-online.target # # [Service] # Restart=always # ExecStart=/usr/bin/podman start -a # ExecStop=/usr/bin/podman stop -t 10 # # [Install] # WantedBy=multi-user.target # ---------------------------------------------------------------------- ################################################################################ FROM localhost/fedora-container-base:fc42 #FROM fedora ARG PROXY_ALLOW_FROM ARG PROXY_PORT=80 ARG PROXY_DOMAIN ARG PROXY_URL RUN echo "################################################################################" \ && echo "##### Installing proxy service #####" \ && echo "################################################################################" \ && : Installation settings \ && export BASE_PACKAGES="httpd mod_ssl langpacks-ja" \ && export BUILD_PACKAGES="net-tools" \ && if [ _ != _${PROXY_URL} ]; then export http_proxy=${PROXY_URL} https_proxy=${PROXY_URL}; fi \ && dnf -y install ${BASE_PACKAGES} ${BUILD_PACKAGES} \ && : Configure httpd.conf \ && sed -e "s/^Listen .*$/Listen ${PROXY_PORT}/g" -i /etc/httpd/conf/httpd.conf \ && : Generate certs \ && /usr/libexec/httpd-ssl-gencerts \ && : Japanese language settings \ && if [ "" != "`echo ${BASE_PACKAGES} ${DESKTOP_PACKAGES} ${BUILD_PACKAGES} | grep 'langpacks-ja'`" ]; then \ ln -sf ../usr/share/zoneinfo/Asia/Tokyo /etc/localtime; \ echo LANG="ja_JP.UTF-8" > /etc/locale.conf; \ fi \ && echo "################################################################################" \ && echo "##### Installing mdns #####" \ && echo "################################################################################" \ && dnf -y install avahi nss-mdns \ && : Configure avahi-daemon.conf \ && sed -e 's/^#enable-dbus=.*$/enable-dbus=no/g' -i /etc/avahi/avahi-daemon.conf \ && if [ _${PROXY_DOMAIN} != _ ]; then \ sed -e "s/^#domain-name=.*$/domain-name=${PROXY_DOMAIN}/g" \ -e "s/^#browse-domains=.*$/browse-domains=${PROXY_DOMAIN}, local/g" -i /etc/avahi/avahi-daemon.conf; \ fi \ && : Generate mdns.allow \ && if [ _${PROXY_DOMAIN} != _ ]; then \ echo -en ".${PROXY_DOMAIN}.\n\ .${PROXY_DOMAIN}\n\ .local.\n\ .local\n"\ > /etc/mdns.allow; \ fi \ && : Configure nsswitch.conf \ && sed -e 's/\(^hosts: .*\) mdns4_minimal \[NOTFOUND=return\] \(.*$\)/\1 mdns4 \2/g' -i /etc/nsswitch.conf \ && : Generating /usr/local/bin/start-httpd \ && echo -en '#!/bin/sh\n\ \n\ trap "/usr/sbin/httpd -k stop" SIGHUP SIGTERM\n\ if [ -f /var/run/avahi-daemon/pid ]; then /usr/sbin/avahi-daemon --kill; rm -f /var/run/avahi-daemon/pid; fi\n\ /usr/sbin/avahi-daemon -D\n\ /usr/sbin/httpd\n\ while [ `ps h -C httpd | wc -l` -gt 0 ]; do sleep 2; done\n\ echo /usr/sbin/httpd stopped.\n\ exit\n'\ > /usr/local/bin/start-httpd \ && chmod a+x /usr/local/bin/start-httpd \ && : Generating /etc/httpd/conf.d/mod_proxy.conf \ && echo -en "\n\ ProxyRequests On\n\ ProxyVia On\n\ \n\ \n\ Order deny,allow\n\ Deny from all\n\ Allow from ${PROXY_ALLOW_FROM}\n\ \n\ \n"\ > /etc/httpd/conf.d/mod_proxy.conf \ && : Removing package cache \ && dnf clean all EXPOSE ${PROXY_PORT} CMD ["/usr/local/bin/start-httpd"]