itnAAnti
itnAAnti

Reputation: 654

NGINX reverse proxy to a URL that requires the sub-domain

I use a third-party web app that has assigned a custom sub-domain to my company. Let's call it http://mycompany.blogsite.com. I do not have any control over blogsite.com, the ports, or my custom sub-domain.

I'm trying to make this accessible on http://mycompany.com/blog/, using NGINX as a reverse proxy.

It returns a 403 or 404 when I visit http://mycompany.com/blog/, which leads me to believe it's not passing the required sub-domain to the remote server - either the subdomain or the path must (?) be getting mangled somehow.

Here's what my config looks like presently, though I've tried several different variations of this:

location /blog/ {
    proxy_pass http://mycompany.blogsite.com;
    proxy_set_header Host $host;
    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;
    proxy_set_header X-Forwarded-Host  $host;
}

Currently, I am testing everything with http, and the remote server does allow it. Eventually I'll need to add ssl, but I figure I'll get this working, first.

Thank you for any pointers!

Upvotes: 2

Views: 1531

Answers (1)

drtechno
drtechno

Reputation: 323

It Should be simple as this:

 location /blog/ {
   proxy_pass http://mycompany.blogsite.com/;
    }

Upvotes: 2

Related Questions