Reverse proxy to Tomcat 8

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Reverse proxy to Tomcat 8

Dino Edwards
Trying to reverse proxy using Nginx to a tomcat 8 application listening on port 8443 but I'm running into an issue where I'm getting status 404 on all static content.

Below is my config file. The /admin location works with no problems. The /ciphermail is the problematic one. I had the exact same problem with static content with the /admin location until I added the following in my server block:

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$

and then it started working. However, the /ciphermail location seems to still not work.

server {
        #LISTEN CONFIG
        listen 80 default_server;
        listen [::]:80 default_server;
        #REDIRECT TO HTTPS UNCOMMENT BELOW TO ENABLE
        #return 301 https://$host$request_uri;
        keepalive_timeout   70;
        #LOGS CONFIG
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log warn;
        proxy_max_temp_file_size 5120m;
        client_max_body_size 5120m;
        # Set the .well-known directory alias for initial Lets Encrypt Certificate
        location /.well-known {
        root /var/www/html/;
        }
        root /var/www/html;
        index index.cfm index.html index.htm;

        location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
        expires 1y;
        }


location /admin {

  #Set Real IP Headers
  proxy_set_header X-Real-IP  $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header Host $host;
  proxy_redirect     off;
  client_max_body_size       10m;
  client_body_buffer_size    128k;

  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;

  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;

  proxy_pass http://localhost:8888/admin/;
}

location /ciphermail {

  #Set Real IP Headers
  proxy_set_header X-Real-IP  $remote_addr;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_set_header Host $host;
  proxy_redirect     off;
  client_max_body_size       10m;
  client_body_buffer_size    128k;

  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;

  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;
  proxy_ssl_verify           off;

  proxy_pass https://localhost:8443/ciphermail/;
}

}
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Reverse proxy to Tomcat 8

Francis Daly
On Sat, Jul 18, 2020 at 01:18:22PM +0000, Dino Edwards wrote:

Hi there,

> Trying to reverse proxy using Nginx to a tomcat 8 application listening on port 8443 but I'm running into an issue where I'm getting status 404 on all static content.

What request do you make? (Probably something like /file.jpg, or
/ciphermail/file.jpg? Give one specific example.)

What response do you get? (You said 404. Do the nginx-or-upstream logs
give any further information?)

What response do you want instead? (This might be "the content of
/usr/local/nginx/html/ciphermail/file.jpg", or "the response from
proxy_pass to https://localhost:8443/ciphermail/file.jpg", or something
else -- be specific,for the example that you gave in the first answer.)

> Below is my config file. The /admin location works with no problems. The /ciphermail is the problematic one. I had the exact same problem with static content with the /admin location until I added the following in my server block:
>
> location ~* \.(jpg|jpeg|png|gif|ico|css|js)$
>
> and then it started working. However, the /ciphermail location seems to still not work.

> location /ciphermail {

Depending on what you want, it might be that you should have "^~" before
and "/" after the word "/ciphermail" in the "location" definition.

Or it might be something else.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

RE: Reverse proxy to Tomcat 8

Dino Edwards

> location /ciphermail {

> Depending on what you want, it might be that you should have "^~" before and "/" after the word "/ciphermail" in the "location" definition.

That seems to have done the trick. Thanks a lot


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx