Nick Ginanto
Nick Ginanto

Reputation: 32160

How to proxy to another URL without redirect

Is it possible to use nginx to work like this:

When going to x.com/blog -> display the content of blog.x.com (with all the query parameters, etc) without changing the browser URL (without browser redirecting)

I tried

location /blog {
 proxy_pass https://blog.x.com
}

but that didn't work

Upvotes: 1

Views: 2360

Answers (1)

mariolu
mariolu

Reputation: 700

This nginx config works for me.

server {
    listen       80;
    listen       [::]:80;
    server_name  x.com;

    location /blog {
        proxy_pass https://blog.x.com;
        proxy_set_header Host blog.x.com;
    }
}

Upvotes: 1

Related Questions