2

Our company develops a new SaaS solution which will be used by resellers and their customers. For the customers of our resellers should the solution be branded like it is a software application from the reseller himself. This is completely implemented exept 1 thing, the URL.

I did a lot of research how to hide an URL/URI and a reverse proxy seems to be the best solution. I read something about different software applications which i can use to build a reverse proxy and Nginx seems to be perfect for this job.

I installed a fresh CentOS server and i installed Nginx on it. It was pretty easy (even for me as Linix noob). After some struggeling with the config file i found how to configure Nginx as reverse proxy.

Now when i browse to my proxy ip (f.e. 192.168.1.100/SaaS) i see the SaaS solution which has another ip. In the address bar i see the reverse proxy ip, exacly as wished!

After i click on a link or button in the SaaS solution the IP in the address bar changes into the real IP of the SaaS solution.

I read this, this, this and many more topics but i cant get it work.

My config "location" part looks like this atm:

location /SaaS {
        proxy_pass http://192.168.1.200/login/;
}

As soon as change it into this (the correct configuration i found on the internet in multiple articles)

location /SaaS {
        proxy_pass http://192.168.1.200/login;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        include /etc/nginx/proxy_params;
}

I got an error "The page you are looking for is not found." from Nginx. What do i wrong?

1
  • 1
    On the second proxy_pass statement you miss a / before the semicolon, which might cause that particular error. However, the SaaS application should make the correct links, since fixing links with search & replace from HTML code is a recipe for problems later on. Oct 10, 2016 at 17:44

1 Answer 1

1

you need to either use a find/replace plugin or update every link in your SaaS app to use the nginx ip (dns would be highly recommend instead)

https://www.nginx.com/resources/wiki/modules/substitutions/

substitute the backend ip with the proxy ip, it's usually possible to rewrite the $host as you have, but it seems your links do not use the variable to set their url.

Example:

server {
    listen       80;
    listen  [::]:80;
    server_name  sub-test.jacobdevans.com;
    root         /var/www/html/test;
 location / {

            sub_filter 'abc-test.jacobdevans.com' 'sub-test.jacobdevans.com';
            sub_filter_once off;
        }

}

server {
    listen       80;
    listen  [::]:80;
    server_name  abc-test.jacobdevans.com;
    root         /var/www/html/test;

 location / {

            sub_filter '123-test.jacobdevans.com' 'abc-test.jacobdevans.com';
            sub_filter_once off;
        }

}

server {
    listen       80;
    listen  [::]:80;
    server_name  123-test.jacobdevans.com;
    root         /var/www/html/test;

 location / {

            sub_filter 'sub-test.jacobdevans.com' '123-test.jacobdevans.com';
            sub_filter_once off;

        }
}

http://sub-test.jacobdevans.com/

2
  • I don't completely understand this. Nginx should be installed on each resellers server. From here it should be "redirect" x.reseller1.com to saas.com/login, same for x.reseller2.com. So change the url in the saas app will not work i think? I tried the find and replace module you send me but i also dont understand that. How do i need to configure nginx so that my url is hidden and the reseller URL stays in the address bar, no mather where i click in the application. Is this even posible? (a detailed how to would be nice...)
    – CodeNinja
    Oct 17, 2016 at 14:17
  • Does this help... sub-test.jacobdevans.com Oct 18, 2016 at 1:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.