Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am facing a strange issue on an application which is deployed on tomcat. Nginx is used in front of tomcat to access the application from browser. The issue is, I deployed the application on tomcat, then set up the virtual host on nginx under conf.d directory. [The file I created is virtual.conf.] Below is the content I am using for the same.

server {
  listen 81;
  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, requests are redirected to I am able to log in to the 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 the redirects from the server section, then I am able to access the application from :81 and able to log into the application, but when I click on any link in app this redirects me to the login page.

I am not getting any logs in application logs or tomcat logs.

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

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.