My first reverse proxy

this is my nginx config file.
For some reason Antrophic and GPT cant solve, when the user visit nginxAPP.fly.dev/blog it still redirects the user to https://wp-blog.fly.dev/blog. Both are fly applications - no clue why it still redirects the user to a whole new url instead of sticking to nginxAPP.fly.dev/blog

Did i do something wrong?

server {
    listen 8080;
    listen [::]:8080;

    server_name nginxAPP.fly.dev;

    # Reverse Proxy for /blog to WordPress
    location /blog {
        proxy_pass https://wp-blog.fly.dev;
        
        # Set WordPress site's domain in headers
        proxy_set_header Host wp-blog.fly.dev;
        proxy_set_header X-Forwarded-Host nginxAPP.fly.dev;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # Handle redirects
        proxy_redirect default;
        proxy_redirect https://wp-blog.fly.dev https://nginxAPP.fly.dev;
        
        # Remove /blog from the URI when proxying
        rewrite ^/blog/(.*) /$1 break;
    }
}

is that intentional or a typo

intentional

That might be why it’s not working, it’s not matching the request headers so nginx doesn’t proxy the route.

lol. didnt realized i posted the real links on the description but thanks for pointing that.
The error persist even after change.

read the nginx docs on that.

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