Simple port forwarding in traefik.

I have a service running on some computer ip:2000 running a simple web server. I have a domain pointing to a server with traefik: git.stuylinux.org. How can I make tunnel requests to git.stuylinu.org to ip:2000?

I found this tutorial (https://freedium.cfd/https://medium.com/@containeroo/traefik-2-0-route-external-services-through-traefik-7bf2d56b1057), but I am just using a single dcker-compose file, so it isn't the same as that tutorial. I don't know where to put the code that I think tunnels the request. If I just named a service called gitea, it would complain about a docker file without an image. I tried just putting that at the end of the traefik service, and it doesn't work.

I am new to traefik, thanks for the help.


docker-compose.yaml

version: "3.7"

services:

traefik:

image: "traefik:v3.1"

container_name: "traefik"

command:

"--api.insecure=true"

"--providers.docker=true"

"--providers.docker.exposedbydefault=false"

"--entryPoints.web.address=:80"

"--entryPoints.websecure.address=:443"

"--entryPoints.ssh.address=:2222"

"--certificatesresolvers.myresolver.acme.httpchallenge=true"

"--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"

"--certificatesresolvers.myresolver.acme.email=axelkeizo@proton.me"

"--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"

"traefik.http.routers.gitea.rule=Host(`git.stuylinux.org`)"

"traefik.http.routers.gitea.entrypoints=websecure,web"

"traefik.http.routers.gitea.tls.certresolver=myresolver"

"traefik.http.services.gitea.loadBalancer.server.url=\"http://206.189.255.201:3000\""

"traefik.http.services.gitea.loadBalancer.passHostHeader=true"

"traefik.http.middlewares.https-redirect.redirectScheme=https"

ports:

"80:80"

"443:443"

"8080:8080"

environment:

"PUID=1000"

"PGID=1000"

volumes:

"./letsencrypt:/letsencrypt"

"/var/run/docker.sock:/var/run/docker.sock:ro"fourget:

image: 4get

restart: unless-stopped

environment:

FOURGET_PROTO=http

FOURGET_SERVER_NAME=Stuy Linux Search

labels:

"traefik.enable=true"

"traefik.http.routers.fourget.rule=Host(`search.stuylinux.org`)"

"traefik.http.routers.fourget.entrypoints=websecure,web"

"traefik.http.routers.fourget.tls.certresolver=myresolver"

Use 3 backticks before and after code/config.

To proxy/forward requests to a different server, you need to use a separate dynamic config file with router and service, which is loaded in static config (traefik.yml or command:) via providers.file (doc).