1

In my previous question here nginx resolve (point) everything to different ip except specific file and subdirectory I asked about resolving my whitelabel website and it's pages to different ip but keep some subfolders and files on my server to load from. It turns out it's quite simple to do it and final solution went out like this:

location /robots.txt {
   alias {DOCROOT};
}
server_name {SERVERNAME};
location ~ /\.php$ {
    proxy_pass  10.10.10.10 <== whitelabel ip;
    proxy_set_header Host            {SERVERNAME};
    proxy_set_header X-Forwarded-For myaccount.whitelabelsite.com;
    proxy_redirect off;
    proxy_set_header Connection "Keep-Alive";
    proxy_buffering off;
}

So here I load everything from my whitelabel website under my domain but still keep robots.txt to load from my hosting and some other files.

The problem now is that I'm using this method I can't login to my account on whitelabel site.

So {SERVERNAME} directive is basically my domain name mydomain.com and when I try to login to mydomain.com/aff/panel it opens the page, it doesn't output any error but just refreshes the page and does nothing. Same goes if someone wants to make a booking or send an email form. It opens pages but doesn't do any actions actually.

When I was using DNS redirection everything worked but now it's not. Am I missing some proxy information or headers post/get actions forwarded to and from whitelabel?

Jeff
  • 203
  • 1
  • 2
  • 14
lonerunner
  • 124
  • 1
  • 3
  • 16

1 Answers1

0

The backend application, at "whitelabelsite.com" might not work properly without the Host set correctly. Set the Host header to the hostname you are proxying to instead of your own.

proxy_set_header Host myaccount.whitelabelsite.com

Are you sure that you need proxy_redirect off? This could prevent the backend site from sending redirects.

Also, not likely related to the problem, but X-Forwarded-For should be the client IP address. nginx has a special variable to add the ip properly.

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

It's a bit of guessing without access to full details, hopefully it helps.

virullius
  • 988
  • 8
  • 22
  • I tried to change the settings but no luck. I checked all logs i could find but i didn't find anything special that directs to any problem. I think the problem is that session when user is logged in does not transfer from whitelabel to my domain or vice version. – lonerunner Mar 23 '18 at 22:34
  • 1
    Proxy pass must include the protocol which is usually HTTP or HTTPS – djdomi Jun 27 '21 at 18:05
  • Well spotted, I missed that. https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass – virullius Jun 28 '21 at 15:14