Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


English

You have nginx at the front end and tomcat hosted internally at port 8080 and you would like to bring Tomcat to the front end accessible via tomcat.sampledomain.com.

In Tomcat's server.xml,

...

add the following connector.


Code Block
titleserver.xml
linenumberstrue
     <Connector port="80809090" protocol="HTTP/1.1"
               connectionTimeout="20000" maxThreads="2000"
               redirectPortscheme="8443"https"
               proxyNameproxyPort="tomcat.sampledomain.com443" proxyPort
               redirectPort="80443" />

In nginx's configuration, add this new site configurationsThis is how the new connector looks like below the original connector for 8080.

Code Block
titlenginx site fileserver.xml
linenumberstrue
server  {
  listen<Connector port="8080" protocol="HTTP/1.1"
        80;
  server_name     tomcat.sampledomain.com;connectionTimeout="20000"
  root             redirectPort="8443" /opt/tomcat/webapps/;
  underscores_in_headers on;

location /jw/web/applog/ {>
               
    proxy_pass http://localhost:8080/jw/web/applog/; <Connector port="9090" protocol="HTTP/1.1"
    proxy_set_header Host $http_host;           connectionTimeout="20000" maxThreads="2000"
    proxy_set_header X-Forwarded-Host $host;
           scheme="https"
             proxy_set_header X-Forwarded-Server $host;
 proxyPort="443"
               redirectPort="443" />

In nginx's configuration, add this new site configurations.

Code Block
titlenginx site file
linenumberstrue
server {
  listen          80;
  server_name     tomcat.sampledomain.com;
  root            /opt/tomcat/webapps/;
  underscores_in_headers on;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

  location / {
        proxy_pass  http://localhost:80809090/;
		proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-NginX-Proxy    true;
		proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host             $http_host;
        proxy_set_header   Upgrade          $http_upgrade;
        proxy_redirect     off;	
		proxy_http_version 1.1;
        proxy_set_header   Connection "upgrade";
  }
}

In addition to this, you may start to notice in Joget's log file that you are getting local IP address instead of client's real IP address. We will need to add this configuration into server.xml under the host node earlier.

...