0

I need to update my nginx config to add some redirection to 2 similar servers (PABX servers). Internally, both of them can be joined at https://internal_FQDN/.

So, now I need to have access to them through the reverse proxy.

As servers have the same kind of url, I have to determine a way to determine which server is wanted.

First I was thinking about something like adding some keyword for differentiate traffic, for first server the keyword "server1", for second server "server2". The url should be https://ReverseProxy_FQDN/server1 or https://ReverseProxy_FQDN/server2.

 location /server1/ {
             proxy_pass  https://$server1_fqdn/;
             proxy_redirect  https://$server1_fqdn/ https://$RPpublic_name/OXE1;
             proxy_set_header        Host $host;
             proxy_set_header        X-Forwarded-Host     $http_host;
             proxy_set_header        X-Real-IP $remote_addr;
             proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
}

But, it doesn't work, I have some error in browser's console :

SyntaxError: expected expression, got '<'

I also try to add the "evil if" :

if ($request_uri ~* "/server1/(.*)") {
         proxy_pass  https://$server1_fqdn/$1;
  }

this time, I can go to the login page of server1 but some images are not loaded, it tries to go to /assets/theme/img/sprite.svg. The keyword "server1" doesn't appear and so, it's not well treated by the RP. (from outside, url to load these elements is https://public_fqdn/assets/theme/img/sprite.svg, which is not correctly redirected by RP: redirect only if the URL contains this keyword "server1").

Same kind of error if I try to login, the used url won't have the keyword "server1".

To make difference between the both servers, I would like to use some keyword in the url to reverse proxy, these keywords should not be included in the url redirected to servers.

Thanks

Fred

  • Some news : for the 504 error, it was just a mistake in the firewall. But, it's not enough ! :( By using the "if", I can go to the login page and when I try to log, the url searched is <Public FQDN for my RP>/api/mgt/1.0/login, so the keyword "server1" is missing and RP will not redirected to the correct server. – FredP Feb 8 '18 at 16:56
  • It's hard for me to understand your problem from the information provided. You would like to run two different applications on one domain, right? But what exactly? Could you please be more specific on what server(s), IP(s), domain(s), vhosts, apps, subfolders you have and what your goal is? Maybe also show your whole (but obfuscated) nginx virtualserver config. – Bob Feb 11 '18 at 6:22
  • Thanks for your answer. I'll try to be more specific. I've one public address for the nginx reverse proxy and 2 servers in my internal domain. These servers are same kind of application (an PABX if you know what it is). Internally, I can join their web admin page simply with their own internal IP address. Now I would like to join them from internet. I try to differentiate them by adding a keyword in the url so, Reverse proxy should be able to route. – FredP Feb 12 '18 at 8:26
  • Ok, for what I understand so far: You have 2 servers. Server 1 (PABX app 1), Server 2 (PABX app 2). All web traffic goes to Server 1, but if url path contains '/login/' or '/configuration/' content should be fetched from server 2 through a proxy_pass. Q: Is this correct? Q: Can you make Server 2 also available on the interet with a public IP? – Bob Feb 12 '18 at 11:41
  • I'm not clear, I will edit the question. In fact, I'm still blocked even for a basic redirection : with my configuration, I added a keyword "server1" to redirect traffic to server1 but it's not OK : If I try the url "Public address IP"/server1, I'm redirected to server1 (the login page is loaded) but, some elements are loading with url "Public address IP" only, Reverse Proxy cannot redirect this kind of request to the good server. The main goal is to have access to server1 with url "Public IP Address"/server1 and to have access to server2 with url "Public IP Address"/server2. – FredP Feb 12 '18 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.