Skip to content

Commit

Permalink
1558
Browse files Browse the repository at this point in the history
  • Loading branch information
nobug committed Dec 24, 2023
1 parent 6943078 commit c054a1d
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 12 deletions.
19 changes: 15 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
FROM nginx:1
FROM nginx:1-bookworm
ARG DEBIAN_FRONTEND='noninteractive'

ARG S6_OVERLAY_VERSION=3.1.6.2
ARG S6_OVERLAY_BASE_URL=https://github.com/just-containers/s6-overlay/releases/download
RUN set -x && \
apt-get update && apt-get install -y xz-utils && \
curl --fail ${S6_OVERLAY_BASE_URL}/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz -SLo- | tar -C / -Jxpf - && \
curl --fail ${S6_OVERLAY_BASE_URL}/v${S6_OVERLAY_VERSION}/s6-overlay-`uname -m| sed 's/armv7l/armhf/g'`.tar.xz -SLo- | tar -C / -Jxpf - && \
apt-get purge -y --auto-remove xz-utils

COPY --from=fatedier/frps:v0.53.2 /usr/bin/frps /usr/bin/frps
COPY rootfs/ /
COPY rootfs-s6-rc/ /

RUN set -x && \
mv /docker-entrypoint.sh /docker-entrypoint-nginx.sh && \
Expand All @@ -10,6 +21,6 @@ RUN set -x && \
apt-get purge -y --auto-remove unzip zip wget && \
rm -rf /var/lib/apt/lists/*

# STOPSIGNAL SIGINT
ENTRYPOINT ["/entry.sh"]
EXPOSE 80 7000
STOPSIGNAL SIGTERM
ENTRYPOINT ["/init"]
EXPOSE 80 7000
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
```bash
docker run -it --rm --name frp-http-server \
-e FRP_SUBDOMAIN_HOST=domain.com \
-e SERVER_IP=$(curl -4s ip.sb) \
-p 80:80 \
-p 7000:7000 \
yanhao98/frp-http-server
Expand Down Expand Up @@ -33,7 +34,13 @@ bash <(curl -s domain.com/client.sh) --local=127.0.0.1:80
- https://stackoverflow.com/questions/4888197/how-To-show-dos-output-when-using-vbscript-exec/4888791#4888791
- [Frps服务端一键配置脚本](https://github.com/MvsCode/frps-onekey)
- [frps-docker](https://github.com/cloverzrg/frps-docker/blob/master/Dockerfile)
- s6-overlay
- https://github.com/just-containers/s6-overlay
- https://skarnet.org/software/s6/index.html
- https://github.com/shinsenter/php/blob/main/src/base-s6/Dockerfile
- https://github.com/technotiger/CashReaper/blob/main/Dockerfile#L33-L34

### tips
```
rm /var/log/nginx/access.log /var/log/nginx/error.log
https://github.com/nginxinc/docker-nginx/blob/4bf0763f4977fff7e9648add59e0540088f3ca9f/mainline/debian/Dockerfile#L102
Expand Down
10 changes: 6 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
version: '3'
services:
frp-http-server:
build: .
container_name: frp-http-server
# tty: true
# stdin_open: true
environment:
- FRP_SUBDOMAIN_HOST=yhfrp.tk
# volumes:
# - ./src/html/client.sh:/usr/share/nginx/html/client.sh
- FRP_SUBDOMAIN_HOST=xxx.com
- SERVER_IP=xxx.xxx.xxx.xxx
ports:
- "80:80"
- "7000:7000"
build: .
8 changes: 4 additions & 4 deletions rootfs/entry.sh → entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ sed -i "s/REPLACE_MAIN_DOMAIN/${FRP_SUBDOMAIN_HOST}/g" /usr/share/nginx/html/cli
sed -i "s/REPLACE_SERVER_IP/${SERVER_IP}/g" /usr/share/nginx/html/client.vbs
sed -i "s/REPLACE_VERSION/${FRPS_VER}/g" /usr/share/nginx/html/client.vbs

print_title "the download folder"
ls -l /usr/share/nginx/html/download
# print_title "the download folder"
# ls -l /usr/share/nginx/html/download

print_title "start nginx"
/docker-entrypoint-nginx.sh nginx -g "daemon on;"

sleep 0.1
# sleep 0.1
print_title "start frps"
exec frps \
exec /usr/bin/frps \
--bind_port="7000" \
--subdomain_host="${FRP_SUBDOMAIN_HOST}" \
--vhost_http_port="7080" \
Expand Down
10 changes: 10 additions & 0 deletions rootfs-s6-rc/etc/s6-overlay/s6-rc.d/10-frps/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/command/with-contenv bash
# shellcheck shell=bash
echo "10-FRP_SUBDOMAIN_HOST: ${FRP_SUBDOMAIN_HOST}"
exec /usr/bin/frps \
--bind_port="7000" \
--subdomain_host="${FRP_SUBDOMAIN_HOST}" \
--vhost_http_port="7080" \
--dashboard_port="7500" \
--dashboard_user="" \
--dashboard_pwd=""
1 change: 1 addition & 0 deletions rootfs-s6-rc/etc/s6-overlay/s6-rc.d/10-frps/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
22 changes: 22 additions & 0 deletions rootfs-s6-rc/etc/s6-overlay/s6-rc.d/20-nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/command/with-contenv bash
# shellcheck shell=bash

FRPS_VER=$(frps -v)
if [ -z "${SERVER_IP}" ]; then
echo "20-SERVER_IP is empty, use ip.sb to get ip"
SERVER_IP=$(curl -4s ip.sb)
fi

echo "20-FRP_SUBDOMAIN_HOST: ${FRP_SUBDOMAIN_HOST}"
echo "20-SERVER_IP: ${SERVER_IP}"
echo "20-FRPS_VER: ${FRPS_VER}"

sed -i "s/REPLACE_MAIN_DOMAIN/${FRP_SUBDOMAIN_HOST}/g" /usr/share/nginx/html/client.sh
sed -i "s/REPLACE_SERVER_IP/${SERVER_IP}/g" /usr/share/nginx/html/client.sh
sed -i "s/REPLACE_VERSION/${FRPS_VER}/g" /usr/share/nginx/html/client.sh

sed -i "s/REPLACE_MAIN_DOMAIN/${FRP_SUBDOMAIN_HOST}/g" /usr/share/nginx/html/client.vbs
sed -i "s/REPLACE_SERVER_IP/${SERVER_IP}/g" /usr/share/nginx/html/client.vbs
sed -i "s/REPLACE_VERSION/${FRPS_VER}/g" /usr/share/nginx/html/client.vbs

exec /docker-entrypoint-nginx.sh nginx -g 'daemon off;'
1 change: 1 addition & 0 deletions rootfs-s6-rc/etc/s6-overlay/s6-rc.d/20-nginx/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.

0 comments on commit c054a1d

Please sign in to comment.