Cloudflare argo tunnel gives bad gateway error in nginx

1.3k Views Asked by At

I have setup argo tunnel on nginx and it’s gives 502 error, but but when it’s dns setup the web server work’s great!!. This is my nginx config and argo tunnel Config. I feel it's issue related to SSL or php fpm. Please do guide

tunnel: 796c6fde-bae0-476f-86d6-3dfd022d6143
credentials-file: /home/cloudcreatr/.cloudflared/796c6fde-bae0-476f-86d6-3dfd022d6143.json

ingress:
  - hostname: wp.cloudcreatr.com
    service: https://localhost:443
    originRequest:
      connectTimeout: 10s
      noTLSVerify: true
  # Catch-all rule, which just responds with 404 if traffic doesn't match any of
  # the earlier rules
  - service: http_status:404
warp-routing:
  enabled: true

Nginx site config

server {

    server_name wp.cloudcreatr.com;
    root /var/www/wp;

    index index.html index.htm index.php;

    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    ssl_certificate         /etc/ssl/cert.pem;
    ssl_certificate_key     /etc/ssl/key.pem;

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all; }
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }

    location / {
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
     }

    location ~ /\.ht {
        deny all;
    }

}
1

There are 1 best solutions below

0
On

You need httpHostHeader: in your originRequest: section, for example:

tunnel: 796c6fde-bae0-476f-86d6-3dfd022d6143
credentials-file: /home/cloudcreatr/.cloudflared/796c6fde-bae0-476f-86d6-3dfd022d6143.json

ingress:
  - hostname: wp.cloudcreatr.com
    service: https://localhost:443
    originRequest:
      connectTimeout: 10s
      noTLSVerify: true
      httpHostHeader: wp.cloudcreatr.com
  # Catch-all rule, which just responds with 404 if traffic doesn't match any of
  # the earlier rules
  - service: http_status:404
warp-routing:
  enabled: true