{"id":19838278,"url":"https://github.com/barisates/traefik-reverse-proxy-for-docker","last_synced_at":"2025-07-01T00:07:01.959Z","repository":{"id":98920159,"uuid":"241306144","full_name":"barisates/traefik-reverse-proxy-for-docker","owner":"barisates","description":"Using Traefik as a reverse proxy to host Docker Containers.","archived":false,"fork":false,"pushed_at":"2020-12-08T08:24:06.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-18T17:56:36.603Z","etag":null,"topics":["docker","reverse-proxy","traefik"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/barisates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-18T08:11:39.000Z","updated_at":"2023-03-07T05:13:04.000Z","dependencies_parsed_at":"2024-01-16T05:47:38.597Z","dependency_job_id":null,"html_url":"https://github.com/barisates/traefik-reverse-proxy-for-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/barisates/traefik-reverse-proxy-for-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barisates%2Ftraefik-reverse-proxy-for-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barisates%2Ftraefik-reverse-proxy-for-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barisates%2Ftraefik-reverse-proxy-for-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barisates%2Ftraefik-reverse-proxy-for-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barisates","download_url":"https://codeload.github.com/barisates/traefik-reverse-proxy-for-docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barisates%2Ftraefik-reverse-proxy-for-docker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262870872,"owners_count":23377312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","reverse-proxy","traefik"],"created_at":"2024-11-12T12:17:13.756Z","updated_at":"2025-07-01T00:07:01.928Z","avatar_url":"https://github.com/barisates.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# traefik-reverse-proxy-for-docker\n\nTraefik'i Docker Container'lar için ters proxy olarak kullanma.\n\n\n### Network\n\nÖncelikle Docker üzerinde Traefik ve uygulama container'larının ortak çalışacağı bir network oluşturuyoruz.\n\n```\ndocker network create web\n```\n\nYeni oluşturduğumuz Docker Network'ümüzü güvenlik duvarı üzerinden yapılandırmamız gerekiyor. Bunun için aşağıdaki adımları takip ediyoruz.\n\n- Yeni oluşturduğumuz Docker Network'ümüzün VPS üzerindeki Connection DEVICE bilgisine erişmemiz gerekiyor. Docker Network'lerini listeliyoruz.\n\n```\ndocker network ls\n```\n\n[![](http://barisates.com/git/traefik/network-ls.png)](http://barisates.com/git/traefik/network-ls.png)\n\nBuradaki NETWORK_ID bilgisi ile VPS üzerindeki network bağlantılarımızı karşılaştırarak doğru bağlantıya yetkilendirme yapacağız.\n\n- Daha sonra VPS üzerindeki network bağlantıları listeliyoruz.\n\n```\nnmcli connection show\n```\n\n[![](http://barisates.com/git/traefik/network-connection.png)](http://barisates.com/git/traefik/network-connection.png)\n\nDEVICE alanındaki değer ile bağlantımıza güvenlik duvarı üzerinden yetkilendirme yapacağız.\n\n- Firewall üzerinden yeni oluşturduğumuz Docker Network'üne yetki tanımlıyoruz.\n\n ```\nfirewall-cmd --permanent --zone=trusted --change-interface=br-ff48477ab8a4\nfirewall-cmd --reload\n```\n\n### Traefik\n\nÖncelikle Traefik Dashboard erişim için bir yönetici parolası oluşturacağız. Traefik yapılandırma dosyasında yönetici giriş bilgileri şifreli bir şekilde tutuluyor. Bu bilgileri iki şekilde şifreleyebilirsiniz.\n\n##### htpasswd kullanarak bilgileri şifreleyebilirsiniz;\n\nÖnce `htpasswd` için gerekli paketleri yüklüyoruz.\n\n```bash\nsudo apt-get install apache2-utils\n```\n\nDaha sonra `htpasswd` ile Dashboard için kullanacağımız şifreyi oluşturuyoruz. `SECURE_PASSWROD` alanına kullanmak istediğini şifrenizi girin.\n\n```bash\nhtpasswd -nb admin SECURE_PASSWROD\n```\n\nProgramdan çıktı şu şekilde görünecektir:\n\n```bash\nadmin:$apr1$9r5rUTis$nqG/J4R7365QtB7JBlc2N0\n```\n\n##### Htpasswd Generator kullanarak bilgileri şifreleyebilirsiniz;\n\nhttps://hostingcanada.org/htpasswd-generator/ adresi üzerinden `Username` ve `Password` alanlarını doldurduktan sonra `Mode` alanını **Apache specific salted MD5 (insecure but common)* seçerek şifrenizi oluşturabilirsiniz.\n\n#### Traefik Yapılandırma Dosyası\n\nTraefik Dashboard şifremizi hazırlıladıktan sonra `traefik.toml` dosyamızı hazırlıyoruz. Ben repo içerisine örnek bir dosya bıraktım.\n\nYapılandırma dosyamız aşağıdaki gibi görünecek;\n\n```toml\ndefaultEntryPoints = [\"http\", \"https\"]\n\n[entryPoints]\n  [entryPoints.dashboard]\n    address = \":8080\"\n    [entryPoints.dashboard.auth]\n      [entryPoints.dashboard.auth.basic]\n        users = [\"admin:YOUR_SECURE_PASSWORD\"]\n  [entryPoints.http]\n    address = \":80\"\n      [entryPoints.http.redirect]\n        entryPoint = \"https\"\n  [entryPoints.https]\n    address = \":443\"\n      [entryPoints.https.tls]\n      [[entryPoints.https.tls.certificates]]\n      certFile = \"certs/yourdomain.com.crt\"\n      keyFile = \"certs/yourdomain.com.key\"\n\n[api]\nentrypoint=\"dashboard\"\n\n[docker]\ndomain = \"yourdomain.com\"\nwatch = true\nnetwork = \"web\"\n```\n- Traefik'i bütün istekleri `https` üzerine yönlendireck şekilde yapılandırıyoruz. \n- Yayın yapacağımız adresimizin sertifika dosyasını örnekteki gibi `.key` ve `.crt` olarak tanımlıyoruz. (Sertifika dosyamızı `.key` ve `.crt` olarak nasıl ayıracağımızı bu repoda anlattım; https://github.com/barisates/docker-registry-server#ssl-certificate)\n- Bir önceki adımda oluşturduğumu şifremiz `YOUR_SECURE_PASSWORD` kısmına gelecek.\n\n#### Traefik Konteynırımızı Çalıştırıyoruz\n\nÖncelikle Traefik için bir `docker-compose` dosyası hazırlıyoruz. Ben repo içerisine örnek bir dosya bıraktım, içerik aşağıdaki gibi görünüyor;\n\n```yml\nversion: \"3\"\nservices:\n  traefik:\n    network_mode: web\n    container_name: traefik\n    restart: always\n    volumes:\n      - /var/run/docker.sock:/var/run/docker.sock\n      - ./traefik.toml:/traefik.toml\n      - ./certs:/certs\n    ports:\n      - 80:80\n      - 443:443\n    labels:\n      - traefik.frontend.rule=Host:monitor.yourdomain.com\n      - traefik.port=8080\n    image: traefik:1.7.2-alpine\n```\n\nDaha sonra `root` klasörüne gidiyoruz. Yapılandırma dosyamızı (traefik.toml), docker-compose ve sertifika dosyalarımızı bu dizine kopyalıyoruz. `root` klasörümüz aşağıdaki gibi görünecektir.\n\n```\nroot\n│   traefik.toml\n│   docker-compose.yml \n└───certs\n     │   yourdomain.com.crt\n     │   yourdomain.com.key\n```\n\nŞimdi Treafik konteynırımızı çalıştırabiliriz;\n\n```bash\ndocker-compose up -d\n```\n\nDocker komutları ile Traefik konteynırınızı başlatmak için;\n\n```bash\ndocker run -d \\\n  --restart always \\\n  -v /var/run/docker.sock:/var/run/docker.sock \\\n  -v $PWD/traefik.toml:/traefik.toml \\\n  -v $PWD/certs:/certs \\\n  -p 80:80 \\\n  -p 443:443 \\\n  -l traefik.frontend.rule=Host:monitor.yourdomain.com \\\n  -l traefik.port=8080 \\\n  --network web \\\n  --name traefik \\\n  traefik:1.7.2-alpine\n```\n\n**Artık aynı VPS üzerinde çalışan Docker konteynırlarınızı, SSL desteği ile birlikte barındırabilirsiniz. Örnek olarak bir uygulamayı yayına alalım;**\n\n```yml\nversion: \"3\"\n\nservices:\n  your-project-name:\n    image: registry.yourdomain.com/your-project:latest\n    network_mode: web\n    container_name: your-project-name\n    restart: always\n    labels:\n      - traefik.backend=your-project-name\n      - traefik.frontend.rule=Host:api.yourdomain.com\n      - traefik.docker.network=web\n      - traefik.port=80\n```\n\nYukarıdaki şekilde bir ayarlama ile uygulamalarınızı Traefik ile yayına alabilirsiniz.\n\n- https://www.digitalocean.com/community/tutorials/how-to-use-traefik-as-a-reverse-proxy-for-docker-containers-on-ubuntu-18-04\n\n- https://medium.com/@xavier.priour/secure-traefik-dashboard-with-https-and-password-in-docker-5b657e2aa15f\n\n- https://hostingcanada.org/htpasswd-generator/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarisates%2Ftraefik-reverse-proxy-for-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarisates%2Ftraefik-reverse-proxy-for-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarisates%2Ftraefik-reverse-proxy-for-docker/lists"}