Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

490
Vistas
Traefik - proxy to backend for angular application

I have set up a proxy with Nginx which is as follows

    server {
       listen       80;
       server_name  localhost;

       location /api {
          proxy_pass https://api.mydomain.com/;
       }

       location / {
         root   /usr/share/nginx/html;
         index  index.html index.htm;      
       }

       error_page   500 502 503 504  /50x.html;
       location = /50x.html {
          root   /usr/share/nginx/html;
       }
    }

my Dockerfile

       FROM node:12-alpine as builder
       WORKDIR /workspace
       COPY ./package.json ./
       RUN npm install
       COPY . .
      RUN npm run build

      FROM nginx
      COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
      COPY --from=builder /app/www /usr/share/nginx/html
      EXPOSE 80
      CMD ["nginx", "-g", "daemon off;"]

This works fine But wants to replace Nginx with Traefik for the above proxy settings. Any help would be much appreciated since I'm very new to traefik.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

With Traefik 2+, you need to configure 2 routers: - One for the API - One for the webapp

For the API proxy, you will have a rule like:

rule = "Host(`example.com`) && Path(`/api`)"

And the webapp will juste have the host as rule

rule = "Host(`example.com`)"

For kubernetes, you can do it in an ingress like that:

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: simpleingressroute
  namespace: default
spec:
  entryPoints:
    - web
  routes:
  - match: Host(`example.com`) && PathPrefix(`/api`)
    kind: Rule
    services:
    - name: mywebapp-svc
      port: 80
  - match: Host(`example.com`)
    Kind: Rule
    services:
    - name: myapi-svc
      port: 80

If the API is not inside the kubernetes cluster, you can define the rule tu use an externalService like that:

---
apiVersion: v1
kind: Service
metadata:
  name: myapi-svc
  namespace: default
spec:
  externalName: api.mydomain.com
  type: ExternalName
over 4 years ago · Santiago Trujillo Denunciar

0

if you want to step up from that manual configuration, you may use Traefik as described here. Watch how he uses docker labels to define how to route HTTP traffic. I personally use caddy docker proxy in docker (swarm, but not required) which I find easier to understand and use

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda