NGINX config: issue to proxy_pass a folder to a subdomain

Viewed 14

I want to display the subdirectory /obvious on the subdomain obvious.example.com

  • I added a CNAM record in Cloudflare to create the subdirectory, pointing to the regular app
  • I added the following to my NGINX config:
server {
    listen 80;
    server_name obvious.example.com;

    location / {
        proxy_pass https://www.example.com/obvious$uri;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
    }

    client_max_body_size 4G;
    keepalive_timeout 10;
}

However, I get a 502 Bad Gateway error. Could you help me pinpoint what I am doing wrong here? Thanks.

0 Answers
Related