Skip to main content

Proxy Connection for Tomcat

Proxy Connection for Tomcat

  • For proxy we are using Nginx, so let us install nginx
While installing nginx I got issue with "libunwind" package. So I've manually downloaded that package and installed it.
# wget ftp://195.220.108.108/linux/centos/7.3.1611/os/x86_64/Packages/libunwind-1.1-5.el7_2.2.x86_64.rpm && rpm -ivh libunwind-1.1-5.el7_2.2.x86_64.rpm

# yum install nginx -y
  • Now for our default configuration files let us have a directory
# cd /etc/nginx
# mkdir vhosts.d
  • Now we need to change the configuration as per our requirement
    • Find the include statement for the config files and add another for our new directory
    • After that remove the server definition under the include statement as we'll have it in our new config
# vi nginx.conf

 include /etc/nginx/vhost.d/*.conf;
  • Now lets go to the vhost.d directory and create a new config file
    • Copy the sample server definition after deleting the existing server definition in the main config file
    • Paste it in the new config file and modify as per your requirements
# cd vhost.d/
# vi default.conf

server {
 listen 80;

 root /opt/tomcat8/webapps/hello/;
 index index.php index.html index.htm;

 server_name localhost;

 location / {
  try_files $uri $uri/ /index.html;
 }

 location ~ \.php$ {
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header Host $host;
  proxy_pass http://127.0.0.1:8080;
 }

 location ~ /\.ht {
  deny all;
 }
}
  • Start Nginx
  • Verify that you are able to hit the webapps/hello without any issue.
# elinks http://localhost

Comments

Popular posts from this blog

Troubleshooting Tomcat using Catalina log

Troubleshooting Tomcat using Catalina log We can get the  catalina  logs in  $CATALINA_HOME/logs Here we'll have a  catalina.out We can see some huge info in that log file. If we want to what exactly happens since the start of tomcat then we need to log that into a new file. By default we have log rotation enabled on this logs. For now let us stop tomcat and nullify the catalina.out file and then start tomcat to have some new info in the catalina.out # service tomcat stop # cd $CATALINA_HOME/logs # :> catalina.out (or) cat /dev/null > catalina.out # ll catalina.out -rw-r----- 1 root root 0 Feb 18 16:19 catalina.out # service tomcat start # ll catalina.out -rw-r----- 1 root root 17341 Feb 18 16:21 catalina.out We can see the log being written after the start of tomcat. Now we can notice the instance giving some information about the starting of tomcat, about the configuration for the startup, path of the servlet instance for which the log is re...

RHVH 4.1 Installation Steps for Red Hat Virtualization Host

Red Hat Virtualization Host (RHVH 4.1) is installed using a special build ( Download Link )of Red Hat Enterprise Linux with only the packages required to host virtual machines. It uses an Anaconda installation interface based on the one used by Red Hat Enterprise Linux hosts, and can be updated through the Red Hat Virtualization Manager or via yum. Using the yum command is the only way to install additional packages and have them persist after an upgrade. In this article we are going to see RHVH 4.1 installation RHVH features a Web interface for monitoring the host’s resources and performing administrative tasks. Direct access to RHVH via SSH or console is not supported, so the Cockpit user interface provides a graphical user interface for tasks that are performed before the host is added to the Red Hat Virtualization Manager, such as configuring networking and deploying a self-hosted engine, and can also be used to run terminal commands via the  Tools > Terminal. Access t...

Managing tomcat application

Tomcat is a servlet application which is ready to use after download. There is no need of installing this application. We can directly start or stop it from the bin directory.  So in such case we should go to the bin directory in the CATALINA_HOME or else we need to use the startup script along with its absolute path. And the same is needed to shut it down. We can use the below script to manage the tomcat application and we neither need to go to the CATALINA_HOME nor to use the absolute path. All we need to do is to change the permissions to make it executable and copy that to /sbin and /etc/init.d/ directories. If we copy this into /etc/init.d/ then also we need to mention the absolute path but we can easily memorize it as we know all the startup scripts exists there. But if we copy that into /sbin then there is absolutely no need of mentioning the path of the file. We can use this like below: # tomcat start|stop|restart|status #!/bin/bash # Author : Arjun S...