Score:0

How to configure nginx proxy on tomcat?

vn flag

There is a raised nginx in docker that looks at the Internet with a public address. There is a site that is running on tomcat in docker on another machine with a private address. I need to configure proxying from nginx to tomcat using the link.

Made it through upstream

upstream tomcat {
  server 192.168.10.10:3005;
}
server {
    listen 80;
    server_name 10.16.160.58;
location /private/link1/ {
               proxy_pass http://tomcat/statistics/login;
               proxy_set_header Upgrade $http_upgrade;
               proxy_set_header Connection $connection_upgrade;
               proxy_set_header Host $host;
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header Forwarded $proxy_add_forwarded;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               proxy_set_header X-Forwarded-Proto $scheme;
               proxy_set_header X-Forwarded-Host $host;
               proxy_set_header X-Forwarded-Port $server_port;
              }
}
server {
    listen      80;
    server_name 10.16.160.58;
    return      301 http://10.16.160.58$request_uri;
}

The link location /private/link1/ redirects to the Tomcat service with a registration form to the site, after authorization the service portal should open, but I get a “500 Internal Server Error” error from nginx.

In the logs I saw 404 on /css

16.18.53.120 - - [18/May/2022:10:37:57 +0000] "GET /statistics/static/css/buttons.css HTTP/1.1" 404 146 "10.16.160.58/private/link1" "Mozilla/ 5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"
16.18.53.120 - - [18/May/2022:10:37:57 +0000] "GET /statistics/static/css/input.css HTTP/1.1" 404 146 "10.16.160.58/private/link1" "Mozilla/ 5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"
16.18.53.120 - - [18/May/2022:10:37:57 +0000] "GET /statistics/static/css/main.css HTTP/1.1" 404 146 "10.16.160.58/private/link1" "Mozilla/ 5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"
16.18.53.120 - - [18/May/2022:10:37:57 +0000] "GET /statistics/static/css/modal.css HTTP/1.1" 404 146 "10.16.160.58/private/link1" "Mozilla/ 5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"
16.18.53.120 - - [18/May/2022:10:37:57 +0000] "GET /statistics/static/css/text.css HTTP/1.1" 404 146 "10.16.160.58/private/link1" "Mozilla/ 5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"
16.18.53.120 - - [18/May/2022:10:38:47 +0000] "POST /statistics/login HTTP/1.1" 404 146 "10.16.160.58/private/link1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0"

Tried to add them

location /private/link1/ {
...
proxy_pass http://tomcat/statistics/static/css/;
}

nginx -t error

How to configure the nginx or tomcat config so that the site portal opens after authorization?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.