Traefik as a simple reverse proxy Http does not work

I use traefik as http reverse proxy. I have two servers created using spring boot. Both servers work fine on ports 8081 and 8082

Traifik web ui is displayed on port 8080 .

I would like to redirect http://localhost:7070/ to http://localhost:8081/ or http://localhost:8082/

Traefik.toml configuration file

 loglevel="INFO" defaultEntryPoints = ["http"] [entryPoints] [entryPoints.http] address = ":7070" [file] [frontends] [frontends.frontend1] backend = "backend1" [frontends.frontend1.routes.test_1] rule = "Host: localhost" [backends] [backends.backend1] [backends.backend1.LoadBalancer] method = "drr" [backends.backend1.healthcheck] path = "/app/health" interval = "60s" [backends.backend1.servers.server1] url = "http://127.0.0.1:8081" weight = 1 [backends.backend1.servers.server2] url = "http://127.0.0.1:8082" weight = 1 [api] [ping] [docker] 

console output

 INFO[2018-03-20T18:38:58+05:30] Using TOML configuration file /home/kasun/apps/temp/traefik.toml INFO[2018-03-20T18:38:58+05:30] Traefik version v1.5.4 built on 2018- 03-15_01:33:52PM INFO[2018-03-20T18:38:58+05:30] Stats collection is disabled. Help us improve Traefik by turning this feature on :) More details on: https://docs.traefik.io/basics/#collected-data INFO[2018-03-20T18:38:58+05:30] Preparing server http &{Network: Address::7070 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc4202a4520} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s INFO[2018-03-20T18:38:58+05:30] Preparing server traefik &{Network: Address::8080 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc4202a4540} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s INFO[2018-03-20T18:38:58+05:30] Starting server on :7070 INFO[2018-03-20T18:38:58+05:30] Starting provider *docker.Provider {"Watch":true,"Filename":"","Constraints":null,"Trace":false, "DebugLogGen eratedTemplate":false,"Endpoint": "unix:///var/run/docker.sock","Domain":"","TLS":null, "ExposedByDefault":true,"UseBindPortIP":false,"SwarmMode":false} INFO[2018-03-20T18:38:58+05:30] Starting server on :8080 INFO[2018-03-20T18:38:58+05:30] Starting provider *file.Provider {"Watch":true,"Filename":"/home/kasun/apps/temp/traefik.toml", "Constraints":null,"Trace":false,"DebugLogGeneratedTemplate":false, "Directory":""} INFO[2018-03-20T18:38:58+05:30] Server configuration reloaded on :7070 INFO[2018-03-20T18:38:58+05:30] Server configuration reloaded on :8080 INFO[2018-03-20T18:38:58+05:30] Server configuration reloaded on :7070 INFO[2018-03-20T18:38:58+05:30] Server configuration reloaded on :8080 WARN[2018-03-20T18:38:58+05:30] HealthCheck has failed [http://127.0.0.1:8081]: Remove from server list WARN[2018-03-20T18:38:58+05:30] HealthCheck has failed [http://127.0.0.1:8082]: Remove from server list WARN[2018-03-20T18:38:58+05:30] HealthCheck has failed [http://127.0.0.1:8082]: Remove from server list WARN[2018-03-20T18:38:58+05:30] HealthCheck has failed [http://127.0.0.1:8081]: Remove from server list 

When I download http://localhost:7070/ from a browser, it gives

Service is unavailable

when I go to the trephine health dashboard enter image description here

Can someone tell me what I'm doing wrong here? I looked through several articles but could not find the correct answer.

+5
source share
1 answer

Suppose you are using Træfik in a container.

127.0.0.1 -> localhost inside the container, not on your local machine.

0
source

Source: https://habr.com/ru/post/1275971/


All Articles