N8N docker origin header issue on workflow editor

I’m a beginner with N8N and trying to install it on a local Docker Desktop environnement on my computer behind IIS.

Now I’m trying to host it on a docker server with the use of named URL’s instead of localhost.

The installation was ok and I’ve managed to activate the licence key from the web admin.

If I try to use the editor in my internal network, all work fine. But when I access externally and go inside a new workflow, I’ve noticed in the right upper corner an error of connection.

Digging inside my container logs revealed a recurrent issue:

Origin header does NOT match the expected origin. (Origin: “n8n.mysite.com", Expected: “127.0.0.1:5678”)

Information on my n8n setup

  • n8n version: 1.101.2
  • Running n8n via Docker
  • Operating system Debian via Windows WSL

Docker compose file

services:
  n8n:
    image: n8nio/n8n
    container_name: n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - GENERIC_TIMEZONE=Europe/Dublin
      - TRUST_PROXY=1
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_HOST=n8n.mysite.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.mysite.com/
      - VUE_APP_URL_BASE_API=https://n8n.mysite.com/
      - N8N_TUNNEL_SUBDOMAIN=n8n
      - N8N_DISABLE_PRODUCTION_MAIN_LOG=true
      - N8N_ALLOW_UNSAFE_WEBHOOK_URL=true
      - N8N_RUNNERS_ENABLED=true
      - N8N_EDITOR_BASE_URL=https://n8n.mysite.com
      - N8N_DISABLE_UI_PROXY=true
      - N8N_SOCKET_IO_URL=wss://n8n.mysite.com

    volumes:
      - ./data:/home/node/.n8n

Many thanks in advance.

Hey @JaderCM hope all is well, welcome to the community.

Do you use any type of reverse proxy?
Have you down’ed and up’ed your docker compose infrastructure after making changes to the docker compose file?

Hey @jabbson all good here. I hope is all good with you too. :slight_smile:

I’m using the Microsoft Internet Information Service (IIS) with 2 additional enabled features:

  • URL Rewrite
  • Application Request Routing

I followed this article to configure the reverse proxy in IIS: Reverse Proxy with URL Rewrite v2 and Application Request Routing | Microsoft Learn

These are the configurations I’m using:

URL Rewrite

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.web>
      <authorization>
         <allow users="*" />
      </authorization>
   </system.web>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="N8N" enabled="true">
                    <match url="(.*)$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <serverVariables />
                    <action type="Rewrite" url="http://127.0.0.1:5678/{R:1}" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>
        <httpErrors errorMode="Detailed" />
    </system.webServer>
</configuration>

Application Request Routing

About the changes in docker compose file, all are followed by docker compose down and docker compose up -d.

Let me highlight something that is making me intrigued. The n8n container logs prints my domain in the line Editor is now acessible via: https://n8n.mysite.com but the Origin Expected: "127.0.0.1:5678".

You could try to set additional headers
HTTP_X_FORWARDED_PROTO (=https) and HTTP_X_FORWARDED_HOST (=n8n.mysite.com) in IIS to see if this will help n8n with the origin.

Will probably look something like

  <serverVariables>
    <set name="HTTP_X_FORWARDED_PROTO" value="https" />
    <set name="HTTP_X_FORWARDED_HOST" value="n8n.mysite.com" />
  </serverVariables>

Thanks for your suggestion @jabbson.

It help me to solve the issue.

In the URL Rewrite I added these 2 server variables and updated the values in the inbound rule.

Steps to solve

  1. In IIS, open the URL Rewrite of the site;
  2. In “Actions” on right side panel, click “View Server Variables…”;
  3. Add 2 server variables:
    • HTTP_X_FORWARDED_PROTO
    • HTTP_X_FORWARDED_HOST
  4. Back to URL Rewrite of the site and edit the existent redirect rule clicking in the rule 2 times;
  5. In “Server Variables” section, add the server variables with the values:
    • HTTP_X_FORWARDED_PROTO = https
    • HTTP_X_FORWARDED_HOST = n8n.mysite.com



All good now!