Facing application redirection issue on nginx+tomcat

Posted by Sunny Thakur on Server Fault See other posts from Server Fault or by Sunny Thakur
Published on 2012-09-26T20:56:03Z Indexed on 2012/09/26 21:39 UTC
Read the original article Hit count: 293

Filed under:
|

I am facing a strange issue on application which is deployed on tomcat and nginx is using in front of tomcat to access the application from browser. The issue is, i deployed the application on tomcat and now setup the virtual host on nginx under conf.d directory [File i created is virtual.conf] and below is the content i am using for the same.

server {
  listen 81;
  server_name domain.com;
  error_log /var/log/nginx/domain-admin-error.log;

location / {
        proxy_pass http://localhost:100;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}

Now the issue is this when i am using rewrite ^(.*) http://$server_name$1 permanent; in server section and access the URL then this redirects to https://domain.com and i am able to log in to app and able to access the links also [I am not using ssl redirection in this host file and i don't know why this is happening]

Now when i removed this from server section then i am able to access the application from :81 and able to logged into the application but when i click on any link in app this redirect me to the login page.

I am not getting any logs in application logs as well as tomcat logs.

Please help on this if this is a redirection issue of nginx.

Thanks, Sunny

© Server Fault or respective owner

Related posts about nginx

Related posts about tomcat