Docker Community Forums

Share and learn in the Docker community.

Nginx Rverse Proxy to Tomcat (simple yes....? NO)


#1

Hi,

I have created a docker-compose file to spin up both an nginx and tomcat image. I use volumised files such /etc/nginx/nginx.conf and /etc/nginx/conf.d/app.conf
Same for Tomcat but with xml config files and webapps.

Both spin up and run fine… on their own. I can browse to Nginx and get the welcom page and the same for Tomcat on their respective ports, 81/8080.

However I cannot proxy the request to the backend tomcat. I’ll admit, I’m Apache and have been for years but I need to experiment.

My nginx.conf hasnt changed, its still default. I have an app.conf for the tomcat application (below). I do try and CMD mv the default.conf in teh tomcat Dockerfile but it still remains along side my app.conf so that maybe causing the issue?
my app.conf config is here: (sorry, couldnt figure out how to post code)
server {
listen *:81;

set $allowOriginSite *;
proxy_pass_request_headers on;
proxy_pass_header Set-Cookie;

access_log /var/log/nginx/access.log combined;
error_log /var/log/nginx/error.log error;

Upload size unlimited

client_max_body_size 0;

location /evf {
proxy_pass http://tomcat:8080;

  proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
  proxy_redirect off;
  proxy_buffering off;
  proxy_set_header Host            $host;
  proxy_set_header X-Real-IP       $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass_header Set-Cookie;

}
}

tomcat:8080 being the name of the service in my docker-compose file.
Any help would be appreciated!

Thank you,
Craig