How to redirect to specific tomcat port from nginx configuration

1: Create a file
/etc/nginx/conf.d/example.conf

2: sudo chmod +x /etc/nginx/conf.d/example.conf

3: Copy this content and change the domain name according to you domain.

server {
    server_name  example.com;
    rewrite ^(.*) http://www.example.com$1 permanent;
}

server {
  listen          80 default_server;
  listen [::]:80 default_server ipv6only=on;
  server_name     www.example.com;
  root            /opt/apache-tomcat-8.0.24/webapps/ROOT;

  location / {
proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
  }
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
}

Comments

Popular posts from this blog

Spring Security ACL