Subpath host configuration with kubernetes

Describe the problem/error/question

Hi there n8n team! I have set up n8n within kubernetes and wanted to make it work with subpath but it is not working. What I mean is that n8n is working with example.com but it is not working with example.com/n8n? is there anyone who can help me to configure it on subpath? is it possible?

What is the error message (if any)?

Please share your workflow

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: n8n
component: deployment
name: n8n-deployment
namespace: n8n-polaris
spec:
replicas: 1
selector:
matchLabels:
app: n8n
component: deployment
template:
metadata:
labels:
app: n8n
component: deployment
spec:
containers:
- name: n8n # Container name is missing in your original YAML.
envFrom:
- configMapRef:
name: n8n-configmap
- secretRef:
name: n8n-secrets
env:
- name: N8N_HOST
value: dev.120428826052.realhandsonlabs.net/n8n
- name: N8N_PATH
value: /n8n/
image: “n8nio/n8n:1.3.1”
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /healthz
port: 5678
scheme: HTTP
# name: n8n
ports:
- containerPort: 5678
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /healthz
port: 5678
scheme: HTTP
resources:
limits:
cpu: “400m”
memory: “400Mi”
requests:
cpu: “400m”
memory: “400Mi”

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: n8n-service-ing
namespace: n8n-polaris
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: ‘[{“HTTP”:5678},{“HTTP”:8080},{“HTTPS”:443}]’
alb.ingress.kubernetes.io/actions.ssl-redirect: ‘{“Type”: “redirect”, “RedirectConfig”: { “Protocol”: “HTTPS”, “Port”: “443”, “StatusCode”: “HTTP_301”}}’
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-east-1:120428826052:certificate/xxxxxxxx
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
alb.ingress.kubernetes.io/healthcheck-path: /healthz
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/group.name: n8n-polaris
spec:
rules:
- host: example.com
- http:
paths:
- path: /n8n
pathType: Prefix
backend:
service:
name: n8n-service-lb
port:
number: 80

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Kylychbek, to be honest I am not quite sure how to correctly deploy n8n under a sub-path these days. Simply setting N8N_N8N_PATH=/n8n/ (like you are doing) does not seem to be enough for me either.

Perhaps @Mutasem can confirm how exactly the frontend handles deployments outside of / and what would need to be configured here?

I have even tried to use customized docker image where I have added VUE_APP_URL_BASE_API
but even with that image is not working
ARG NODE_VERSION=18

1. Create an image to build n8n

FROM n8nio/base:${NODE_VERSION} as builder

COPY --chown=node:node turbo.json package.json .npmrc pnpm-lock.yaml pnpm-workspace.yaml jest.config.js tsconfig*.json ./
COPY --chown=node:node scripts ./scripts
COPY --chown=node:node packages ./packages
COPY --chown=node:node patches ./patches

RUN apk add --update jq
RUN corepack enable && corepack prepare --activate
USER node

RUN pnpm install --frozen-lockfile
RUN pnpm build
RUN rm -rf node_modules
RUN jq ‘del(.pnpm.patchedDependencies)’ package.json > package.json.tmp; mv package.json.tmp package.json
RUN node scripts/trim-fe-packageJson.js
RUN NODE_ENV=production pnpm install --prod --no-optional
RUN find . -type f -name “.ts" -o -name ".js.map” -o -name “.vue" -o -name “tsconfig.json” -o -name ".tsbuildinfo” | xargs rm -rf
RUN rm -rf packages/@n8n_io/eslint-config packages/editor-ui/src packages/editor-ui/node_modules packages/design-system
RUN rm -rf patches .npmrc .yaml node_modules/.cache packages//node_modules/.cache packages//.turbo .config .cache .local .node /tmp/

2. Start with a new clean image with just the code that is needed to run n8n

FROM n8nio/base:${NODE_VERSION}
ARG N8N_RELEASE_TYPE=dev
COPY --from=builder /home/node /usr/local/lib/node_modules/n8n
RUN ln -s /usr/local/lib/node_modules/n8n/packages/cli/bin/n8n /usr/local/bin/n8n

COPY docker/images/n8n/docker-entrypoint.sh /

RUN
mkdir .n8n &&
chown node:node .n8n
USER node
ENV NODE_ENV=production
ENV VUE_APP_URL_BASE_API=example.com/n8n
ENV N8N_RELEASE_TYPE=${N8N_RELEASE_TYPE}
ENTRYPOINT [“tini”, “–”, “/docker-entrypoint.sh”]

but it is same and it is giving same error

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