Url rewrite issue

location /
{
rewrite ^/apps/(.*)$ /$1?$args break;
proxy_pass http://localhost:8080; # Intrexx Portal
}

location /intrexx/
{
rewrite ^/apps/(.*)$ /$1?$args break;
proxy_pass http://localhost:8109/intrexx/; # Intrexx Webservices
}

i want to convert this nginx config to treafik v2 reverse proxy and having issue with url rewrite

rewrite ^/apps/(.*)$ /$1?$args break;

can someone help me to convert this expression to treafik v2

See example from simple Traefik example (link):

  whoami:
    image: traefik/whoami:v1.10
    networks:
      - proxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.mywhoami.rule=Host(`whoami.example.com`) || Host(`www.whoami.example.com`)
      - traefik.http.services.mywhoami.loadbalancer.server.port=80

      - traefik.http.middlewares.mywwwredirect.redirectregex.regex=^https://www\.(.*)
      - traefik.http.middlewares.mywwwredirect.redirectregex.replacement=https://$${1}
      - traefik.http.routers.mywhoami.middlewares=mywwwredirect

Use $$ when using labels in compose

# middlewares.yml
http:
  middlewares:
    rewrite-intrexx:
      redirectRegex:
        regex: "^/apps/(.*)"
        replacement: "/${1}"
        permanent: true
  
    headers-intrexx:
      headers:
        customRequestHeaders:
          X-Real-IP: "X-Real-IP"
          X-Forwarded-For: "X-Forwarded-For"
          Host: "Host"
          X-Forwarded-Proto: "X-Forwarded-Proto"
  
# services.yml
http:
  services:
    intrexx-portal:
      loadBalancer:
        servers:
          - url: "http://<ExternalServiceIP>:8080"
        passHostHeader: true
  
    intrexx:
      loadBalancer:
        servers:
          - url: "http://<ExternalServiceIP>:8109/intrexx/"
        passHostHeader: true
  
# routers.yml
http:
  routers:
    intrexx-portal-router:
      rule: "Host(`mydomain.com`,`www.mydomain.com`)"
      entryPoints:
        - "websecure"
      service: intrexx-portal
      middlewares:
        - "rewrite-intrexx"
        - "headers-intrexx"
      tls:
        certresolver: "le"
  
    intrexx-router:
       rule: "Host(`mydomain.com`,`www.mydomain.com`) && PathPrefix(`/intrexx`)"
      entryPoints:
        - "websecure"
      service: intrexx
      middlewares:
        - "default-headers"
      tls:
        certresolver: "le"

here is my configuration. I am using dynamic configuration.

rule: "Host(mydomain.com,www.mydomain.com) && PathPrefix(/intrexx)" works fine but intrexx-portal through HTTP Status 400 – Bad Request

Why do you set those? They are set by Traefik automatically.

And it seems you set them wrong, host needs to contain the domain, otherwise your target service might not work.

:grinning: Just trying to make it work. do you can any idea how to configure Apache Tomcat/8.5.60 behind traefik v2 proxy?

Did you remove those parts from your config?

Enable and check Traefik debug log (doc) and Traefik dashboard (doc).