caprover / one-click-apps

Community Maintained One Click Apps (https://github.com/caprover/caprover)
Apache License 2.0
525 stars 513 forks source link

App Suggestion: Gost #1117

Closed amirsaam closed 1 week ago

amirsaam commented 2 weeks ago

Please tell us what app you'd like to see on CapRover as a one-click app. Gost is a simple security tunnel written in golang, it would be lovely if we can have its WebUI on top of it too. It is a very powerful app in order to get free internet by tunneling a domestic ip server to a foreign one.

Do you know if there is any official Docker image for the app? Yes, there is an official docker image for the app available as ginuerzh/gost, Gost docs

amirsaam commented 1 week ago
captainVersion: 4
services:
    $$cap_appname:
        environment:
            TZ: $$cap_gost_ubuntutimezone
            TARGET_SERVER_IP: $$cap_gost_targetip
            TARGET_SERVER_NONSSL_PORT: $$cap_gost_ip_nonsslport
            TARGET_SERVER_SSL_PORT: $$cap_gost_ip_sslport
            GOST_NONSSL_PORT: $$cap_gost_nonsslport
            GOST_SSL_PORT: $$cap_gost_sslport
#        ports:
#            - $$cap_gost_container_nonsslport:8888
#            - $$cap_gost_container_sslport:2222
        caproverExtra:
            notExposeAsWebApp: false
            dockerfileLines:
                - FROM ubuntu:$$cap_gost_ubuntuversion
                - ENV DEBIAN_FRONTEND=noninteractive
                - ENV TZ=$$cap_gost_ubuntutimezone
                - ENV GOST_NONSSL_PORT=$$cap_gost_nonsslport
                - ENV GOST_SSL_PORT=$$cap_gost_sslport
                - ENV TARGET_SERVER_IP=$$cap_gost_targetip
                - ENV TARGET_SERVER_NONSSL_PORT=$$cap_gost_ip_nonsslport
                - ENV TARGET_SERVER_SSL_PORT=$$cap_gost_ip_sslport
                - USER root
                - RUN apt update && apt install -y wget curl
                - RUN wget -q https://github.com/ginuerzh/gost/releases/download/v2.11.5/gost-linux-amd64-2.11.5.gz
                - RUN gunzip -q gost-linux-amd64-2.11.5.gz
                - RUN mv gost-linux-amd64-2.11.5 /usr/local/bin/gost
                - RUN chmod +x /usr/local/bin/gost
                - RUN echo -e "#!/bin/bash\nprintenv\nexec /usr/local/bin/gost -L=tcp://:${GOST_NONSSL_PORT}/${TARGET_SERVER_IP}:${TARGET_SERVER_NONSSL_PORT} -L=tcp://:${GOST_SSL_PORT}/${TARGET_SERVER_IP}:${TARGET_SERVER_SSL_PORT}" > /start.sh
                - RUN chmod +x /start.sh
                - ENTRYPOINT ["/bin/bash", "/start.sh"]
caproverOneClickApp:
    variables:
        - id: $$cap_gost_ubuntuversion
          label: Ubuntu Version
          description: Check out https://hub.docker.com/_/ubuntu/tags for valid tags.
          defaultValue: 22.04
        - id: $$cap_gost_ubuntutimezone
          label: Timezone
          description: Timezone for the application, find yours at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
          defaultValue: Asia/Tehran
          validRegex: /.{1,}/
        - id: $$cap_gost_nonsslport
          label: Exposed Non-SSL port for Gost
          description: Make sure it's not taken
          defaultValue: 80
          validRegex: /^\d+$/
        - id: $$cap_gost_sslport
          label: Exposed SSL port for Gost
          description: Make sure it's not taken
          defaultValue: 443
          validRegex: /^\d+$/
        - id: $$cap_gost_targetip
          label: The IP you want Gost to make tunnel to
          description: Enter an IP address
          defaultValue: 0.0.0.0
        - id: $$cap_gost_ip_nonsslport
          label: Non-SSL port of the target IP address
          description: Enter a port number
          defaultValue: 80
          validRegex: /^\d+$/
        - id: $$cap_gost_ip_sslport
          label: SSL port of the target IP address
          description: Enter a port number
          defaultValue: 443
          validRegex: /^\d+$/
    instructions:
        start: Make sure to use correct values because ENV variables cannot change the service values afterwards.
        end: The container is built and deployed. 
    displayName: Gost Simple Tunnel
    isOfficial: false
    description: A simple security tunnel written in golang
    documentation: Read their official docs at https://v2.gost.run/en/

ok, so this is what works and what does not work:

this is how we use Gost on a plain Ubuntu server:

wget -q https://github.com/ginuerzh/gost/releases/download/v2.11.5/gost-linux-amd64-2.11.5.gz
gunzip -q gost-linux-amd64-2.11.5.gz
mv gost-linux-amd64-2.11.5 /usr/local/bin/gost
chmod +x /usr/local/bin/gost
touch /usr/lib/systemd/system/gost.service
systemctl start gost
sudo systemctl enable gost

and the gost.service file contains:

[Unit]
Description=GO Simple Tunnel
After=network.target
Wants=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/gost -L=tcp://:gostPort/domainOrIP:port

[Install]
WantedBy=multi-user.target

I'll appreciate any help.