# N8N Behind HTTPS\_PROXY

**URL:** <https://community.n8n.io/t/n8n-behind-https-proxy/84913>\
**Category:** Questions\
**Created:** [March 6, 2025, 6:09am UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913 "2025-03-06T06:09:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikas\_Bukhari](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/vikas_bukhari/32/62770_2.png) [@Vikas\_Bukhari](https://community.n8n.io/u/Vikas_Bukhari)\
**Post date:** [March 6, 2025, 6:09am UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/1 "2025-03-06T06:09:19Z")

</div>

When running N8N Behind Http proxy, it does not work and gives bad gateway error, here the issue is that the requests are going properly and proxy is responding properly to the messages but N8N shows Bad Gateway error.

## What is the error message (if any)?

502 - "\n\n\<meta type="copyright" content="Copyright (C) 1996-2019 The Squid Software Foundation and contributors"\>\n\<meta http-equiv="Content-Type" content="text/html; charset=utf-8"\>\nERROR: The requested URL could not be retrieved\n\<style type="text/css"\>\<!-- \n /\*\n \* Copyright (C) 1996-2020 The Squid Software Foundation and contributors\n

I am using simple workflow to send messages via slack to channel.

## Share the output returned by the last node

Bad gateway - the service failed to handle your request  
ERROR: The requested URL could not be retrieved ERROR The requested URL could not be retrieved  
The following error was encountered while trying to retrieve the URL:  
**Read Error**

The system returned: _[No Error]_

An error condition occurred while reading data from the network. Please retry your request.

Your cache administrator is webmaster.

---

<div class="post-metadata">

**Author:** ![Knight](https://avatars.discourse-cdn.com/v4/letter/k/2bfe46/32.png) [@Knight](https://community.n8n.io/u/Knight)\
**Post date:** [March 6, 2025, 5:15pm UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/2 "2025-03-06T17:15:55Z")

</div>

@Vikas_Bukhari, did you set the `N8N_PROXY_HOPS` environment variable as stated in [here](https://docs.n8n.io/hosting/configuration/environment-variables/deployment/)?

---

<div class="post-metadata">

**Author:** ![Vikas\_Bukhari](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/vikas_bukhari/32/62770_2.png) [@Vikas\_Bukhari](https://community.n8n.io/u/Vikas_Bukhari)\
**Post date:** [March 7, 2025, 8:24am UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/3 "2025-03-07T08:24:05Z")

</div>

Yes, I tried modfying the parameter, but It is still not working. Same errror is coming. @Knight

---

<div class="post-metadata">

**Author:** ![Vikas\_Bukhari](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/vikas_bukhari/32/62770_2.png) [@Vikas\_Bukhari](https://community.n8n.io/u/Vikas_Bukhari)\
**Post date:** [March 7, 2025, 10:12am UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/4 "2025-03-07T10:12:51Z")

</div>

This is the docker-compose.yml file

@Knight

````auto
version: "3.3" # <-- Add this line if needed

services:
  n8n:
    image: IMAGE
    container_name: n8n
    restart: unless-stopped
    environment:
      - N8N_HOST=HOST_NAME
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_EDITOR_BASE_URL=BASE_URL/
      - WEBHOOK_URL=BASE_URL/
      - WEBHOOK_TUNNEL_URL=BASE_URL/
      - HTTP_PROXY=http://tinyproxy.XXXX.is1:8888 # Use HTTP proxy
      - https_proxy=http://tinyproxy.XXXX.is1:8888
      - http_proxy=http://tinyproxy.XXXX.is1:8888
      - HTTPS_PROXY=http://tinyproxy.XXXX.is1:8888 # Use HTTP proxy
      - NO_PROXY=localhost,127.0.0.1,yourdomain.com
      - NODE_TLS_REJECT_UNAUTHORIZED=0 # Disable SSL verification
      - CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
      - DEBUG=*
      - LOG_LEVEL=debug
      - N8N_USE_DEPRECATED_REQUEST_LIB=true
      - NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt
      - N8N_PROXY_HOPS=4
      - N8N_DIAGNOSTICS_ENABLED=false
      - N8N_VERSION_NOTIFICATIONS_ENABLED=false
      - N8N_TEMPLATES_ENABLED=false
    extra_hosts:
      - "host.docker.internal:host-gateway"
    network_mode: "host" # Alternative networking approach
    ports:
      - "5678:5678"
    volumes:
      - ~/.n8n:/home/node/.n8n```
````

---

<div class="post-metadata">

**Author:** ![Vikas\_Bukhari](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/vikas_bukhari/32/62770_2.png) [@Vikas\_Bukhari](https://community.n8n.io/u/Vikas_Bukhari)\
**Post date:** [March 7, 2025, 4:09pm UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/5 "2025-03-07T16:09:41Z")

</div>

It does not only happen with Slack, It happens with all outbound http / https calls. @Knight

---

<div class="post-metadata">

**Author:** ![Vikas\_Bukhari](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/vikas_bukhari/32/62770_2.png) [@Vikas\_Bukhari](https://community.n8n.io/u/Vikas_Bukhari)\
**Post date:** [March 8, 2025, 7:27am UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/6 "2025-03-08T07:27:02Z")

</div>

@Knight Can you help here?

---

<div class="post-metadata">

**Author:** ![Knight](https://avatars.discourse-cdn.com/v4/letter/k/2bfe46/32.png) [@Knight](https://community.n8n.io/u/Knight)\
**Post date:** [March 9, 2025, 7:26pm UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/7 "2025-03-09T19:26:09Z")

</div>

@Vikas_Bukhari Try this:

```auto
version: '3.3'

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    container_name: n8n
    ports:
      - "5678:5678"
    environment:
      - N8N_ENCRYPTION_KEY=db1cef92-ee4d-4b83-a807-999ea50e573b
      - N8N_PROXY_HOPS=1
      - WEBHOOK_URL=https://<NGROK_DOMAIN>
      - N8N_DIAGNOSTICS_ENABLED=false
      - N8N_VERSION_NOTIFICATIONS_ENABLED=false
      - N8N_TEMPLATES_ENABLED=false
    volumes:
      - ~/.n8n:/home/node/.n8n
    restart: unless-stopped
    stdin_open: true
    tty: true

```

Make sure to replace `https://<NGROK_DOMAIN>` with the url you received from the proxy. Check also if the proxy is forwarding it’s requests to `localhost:5678`.

---

<div class="post-metadata">

**Author:** ![Knight](https://avatars.discourse-cdn.com/v4/letter/k/2bfe46/32.png) [@Knight](https://community.n8n.io/u/Knight)\
**Post date:** [March 30, 2025, 11:52pm UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/8 "2025-03-30T23:52:03Z")

</div>

@Vikas_Bukhari,  
Has your issue been resolved? If so, please mark the solution or mention it so others can benefit from the fix.

---

<div class="post-metadata">

**Author:** ![q7joey](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/q7joey/32/85737_2.png) [@q7joey](https://community.n8n.io/u/q7joey)\
**Post date:** [May 30, 2025, 6:18pm UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/9 "2025-05-30T18:18:59Z")

</div>

Make sure your proxy is configured to pass the host name, for apache that is:

ProxyPreserveHost On

and the full proxy config is:

```
RewriteEngine On
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteRule ^/?(.*) "ws://localhost:5678/$1" [P,L]
RewriteCond %{HTTP:UPGRADE} !^WebSocket$ [NC]
RewriteRule ^/?(.*) "http://localhost:5678/$1" [P,L]
ProxyPassReverse / http://localhost:5678/
ProxyPreserveHost On

```

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/36532_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [August 28, 2025, 6:19pm UTC](https://community.n8n.io/t/n8n-behind-https-proxy/84913/10 "2025-08-28T18:19:46Z")

</div>

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