0

I have a java app which has login section for all users (http://192.168.0.101:8080/login) and admin section for admins(http://192.168.0.101:8080/admin).

I want to run this app in two servers for different users.

http://192.168.0.101:8080/ >> Normal Users + Admins

http://192.168.0.102:8080/admin >> Admins Only

I am trying this with nginx.

server {
    listen 80;

    server_name domain.com;

    location / {
        proxy_pass                          http://192.168.0.101:8080/;
        proxy_redirect off;
            proxy_set_header Host               $host;
            proxy_set_header X-Real-IP          $remote_addr;  
            proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
    }


    location /admin/ {
                proxy_pass                          http://192.168.0.102:8080/admin/;
        proxy_redirect off;
                proxy_set_header Host               $host;
                proxy_set_header X-Real-IP          $remote_addr;
                proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
        }
}

My nginx is in http://192.168.0.103/ Now, if i access http://192.168.0.103/, it shows me data from http://192.168.0.101:8080/. which is ok. But if i try http://192.168.0.103/admin then it takes me to http://192.168.0.101:8080/login as login page is for all users(including admins).

What can i do about it ?

By the all i am trying to do is to reduce load on the server. It eat a lot of CPU with 60-65 users(not admins) at a time ... :(

Admin section has a lot of tasks which leave impact on server.

So, i was planning to run application in two different server with same DB and balance the load. Any Suggestion ?

Fahad Ahammed
  • 113
  • 1
  • 7
  • Please post your full config, including nginx.conf and the file(s) that define the server configuration (ie the bit with server { and the server_name directives) – Tim Aug 03 '16 at 04:59
  • Did that, so let domain.com is pointed to 192.168.0.103.... @Tim – Fahad Ahammed Aug 03 '16 at 05:05
  • TIM, let me be more clear. I have a front server with nginx on it. FRONT: A Public accessible IP. (Running NGINX which is pointed with a domain) BACK1: 192.168.0.101 (full app install but want to serve to both clients/users and admins) BACK2: 192.168.0.102 (full app installed but want to serve to those who are admins who will access only admin section) – Fahad Ahammed Aug 03 '16 at 05:30
  • The way you've written this is fairly confusing. I think your application is doing the forward to /login as the word "login" doesn't appear in your nginx configuration. Please post the nginx access logs for an applicable request, along with the application access log if it has one. – Tim Aug 03 '16 at 05:30
  • @Tim , http://pastebin.com/YaR2Mh9k : Accesslog – Fahad Ahammed Aug 03 '16 at 05:39
  • The access logs shows a 302 redirect being sent from your application back to the client. I think you need to reconsider what you're doing, why, and how. If you post more about what you're trying to achieve, not just the method you're using to attempt it, you might get some useful suggestions. – Tim Aug 03 '16 at 07:31
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/43396/discussion-between-fahad-ahammed-and-tim). – Fahad Ahammed Aug 03 '16 at 07:51
  • @Tim , I have edited my question. I appreciate your time. It will be very if anyone can help me getting a solution about the problem. – Fahad Ahammed Aug 03 '16 at 07:53
  • Is it possible that problem in your application server? What will your application returns for http://192.168.0.102:8080/admin/ ? – toshyak Aug 03 '16 at 14:55
  • @toshyak , it works well. I think i have got my problem in application server itself. It redirects from /admin to /login.... session problem... I will post the probable solution for this. – Fahad Ahammed Aug 04 '16 at 02:43

0 Answers0