Simple reverse proxy with Traefik

18,621

You are missing the backend type definition (file, Docker, Swarm...).

In your case just add (or uncomment) [file] in your conf file, like that:

defaultEntryPoints = ["http"]
[entryPoints]
  [entryPoints.http]
  address = ":80"

[file]

[backends]
  [backends.backend1]
    [backends.backend1.servers.server1]
       url = "http://10.0.0.142"

[frontends]
  [frontends.frontend1]
      backend = "backend1"
      passHostHeader = true
      [frontends.frontend1.routes.example]
          rule = "Host:example.com"
Share:
18,621

Related videos on Youtube

lepe
Author by

lepe

I work as a server administrator / developer in Japan. I also assist some companies to strengthen their network security as freelancer.

Updated on September 18, 2022

Comments

  • lepe
    lepe almost 2 years

    I'm currently using Apache as proxy for my LXD containers, using this kind of settings:

    <VirtualHost *:80>
        ServerName example.com
        ProxyRequests off
        ProxyPass / http://10.0.0.142/ retry=0
        ProxyPassReverse / http://10.0.0.142/
        ProxyPreserveHost On
    </VirtualHost>
    

    I would like to switch to traefik. I have tried this configuration:

    defaultEntryPoints = ["http"]
    [entryPoints]
      [entryPoints.http]
      address = ":80"
    
    [backends]
      [backends.backend1]
        [backends.backend1.servers.server1]
           url = "http://10.0.0.142"
    
    [frontends]
      [frontends.frontend1]
          backend = "backend1"
          passHostHeader = true
          [frontends.frontend1.routes.example]
              rule = "Host:example.com"
    
    • Are these two equivalent?
    • Can the traefik configuration be simplified? (remove unnecessary rules)

    (Note: I'm not planning on using docker, and I would prefer not to.)

  • lepe
    lepe about 7 years
    So [file] is required? I didn't find anything about that. Why its so?
  • Benjamin OLIVIER
    Benjamin OLIVIER about 7 years
    yes it is if you simply want to manually create rules statically in a configuration file. You can refer to the doc: https://docs.traefik.io/toml/#file-backend
  • lepe
    lepe about 7 years
    ok. got it. Thanks! (do you mind to upvote my question? not sure why it was downvoted)
  • andig
    andig over 6 years
    Good question- was stuck there for an hour...
  • SeanDowney
    SeanDowney about 6 years