How would you forward test.example.com to test.local.example.com when it hits traefik?

Hi,

I have a domain like "nextcloud.example.com". It is pointing to my Nextcloud server.
This Nextcloud server is running on docker and managed by traefik and is working fine using SSL certs and is on "Nextcloud.local.example.com"
How do I forward "nextcloud.example.com" to "nextcloud.local.fahadusman.com" when it hits my traefik VM?

Cheers

When both services are in Docker, you can use configuration discovery, like simple Traefik example.

If you explicitly want to create a Traefik router proxying/forwarding requests to another domain, you need to use a dynamic config file, like simple Traefik forward example.

thank you for reply. From the Internet the traffic hits to my traefik VM using url: nextcloud.example.com and that needs to be forwarded to nextcloud.local.example.com which is managed by traefik but I am getting 404 page not found...
Here is what I did:

http:
  #region routers
  routers:
    nextcloud-forward:
      entryPoints:
        - "https"
      rule: Host(`nextcloud.example.com`)
      middlewares:
        - nextcloud-addHost
      service: nextcloud-forward

  services:
    nextcloud-forward:
      loadBalancer:
        servers:
          - url: https://nextcloud.local.example.com

middlewares:
    addHost:
      headers:
        customRequestHeaders:
          Host: https://nextcloud.local.example.com

You have 2 Traefik instances running?

If the forwarded request should have the host header of the forwarded domain, not from the original request, then you can try to set passHostHeader: false (doc):

## Dynamic configuration
http:
  services:
    Service01:
      loadBalancer:
        passHostHeader: false

Hi thanks again. Here is the complete end to end scenario what I am trying to achieve:

did any one resolve this? I thought it would be easy to forward traffic from 1 traefik instance to another? All I need is to forward traffic coming into traefik instance 1 on https://service.example.com to another traefik instance handling https://service.local.example.com

Just to clarify that there are two traefik docker instances running:

  1. to handle public facing services like test.example.com
  2. to handle internal services like test.local.example.com

I want the public facing traefik instance to forward traffic to internal services handling traefik instance. So if the host is test.example.com...it should be forwarded to test.local.example.com managed by a second traefik instance

Should be possible, what's your issue?

You just need to make a decision if you want to forward internally with or without TLS.

I resolved it by:

http:
  #region routers
  routers:
    service_on_different_vm:
      entryPoints:
        - "https"
      rule: "Host(`service.example.com`)"
      middlewares:
        - default-headers
        - https-redirectscheme
      tls: {}
      service: service_on_different_vm

#endregion
  #region services
  services:
    service_on_different_vm:
      loadBalancer:
        servers:
          - url: "https://service.local.example.com"
        passHostHeader: false

The only thing you need to make sure is that your firewall is not blocking traffic between the two instances 😂😂🤭

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.