Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bad Gateway returned by Nginx #39

Closed
pvannierop opened this issue Jun 25, 2020 · 2 comments
Closed

[BUG] Bad Gateway returned by Nginx #39

pvannierop opened this issue Jun 25, 2020 · 2 comments

Comments

@pvannierop
Copy link

pvannierop commented Jun 25, 2020

When compose services have started and xnat is accessed on http://localhost Nginx returns a bad gateway error.

image

The logs of Nginx show:

2020/06/25 06:50:28 [error] 6#6: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.0.1, server: , request: "GET / HTTP/1.1", upstream: "http://172.31.0.3:8081/", host: "localhost"
2020/06/25 06:50:28 [error] 6#6: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.31.0.3:8081/favicon.ico", host: "localhost", referrer: "http://localhost/"

To Reproduce
Steps to reproduce the behavior:

  1. Clone repository.
  2. Check out branch master
  3. Run docker-compose up -d and wait for the Xnat service to start.
  4. Attach shell to xnat-nginx service:
docker exec -it xnat-docker-compose_xnat-nginx_1 sh
  1. Inspect error log:
tail -f /var/log/nginx/xnat.error.log
  1. Open http://localhost in browser
  2. Check Nginx log (see Step 4)

Expected behavior
I expect to be redirected to the xnat-web service.

Docker server environment (please complete the following information):

  • Ubuntu 18.04
  • Docker version 19.03.11, build 42e35e61f3
  • docker-compose version 1.25.4, build 8d51620a

Configuration:

  • Branch of XNAT docker-compose project:master
  • Commit hash or tag: d96eaeb
  • Environment settings: none
  • Configuration: none

Additional context

image

  • On a side note: wthat is the reason for exposing ports 8000 and 8080 on the host system by the xnat-web service? Should all traffic not go through Nginx?
@pvannierop pvannierop changed the title [BUG] Bad Gateway returned Nginx [BUG] Bad Gateway returned by Nginx Jun 25, 2020
@rherrick
Copy link
Contributor

The answer is in the nginx error log:

upstream: "http://172.31.0.3:**8081**/"

The proxy is configured to redirect to port 8081, so it's not surprising that XNAT running on port 8080 isn't responding. I'm not sure why you're getting that configuration: there is an nginx configuration in the file nginx/xnat, but it's not referenced by anything and shouldn't be active (I'm going to delete it actually). nginx/Dockerfile references nginx/nginx.conf, which is what's active when I run this configuration without modification.

Revert any changes you've made to the configuration, whether to nginx.conf, to reference nginx/xnat, or whatever it is that's getting the nginx configuration to redirect to port 8081 on the XNAT container. If you update to the latest commit (which I'll push momentarily), the nginx/xnat configuration has been removed. There is no other reference to port 8081 in the project.

As for why 8080 and 8000 are published ports, that's a relic of this project being used primarily as a development platform: 8080 for exactly what you did (validating that XNAT is working without proxy) and 8000 for attaching to container JVM to debug code. I removed that and also added environment variables to make it possible to change heap size settings. The default minimum and maximum are 256m (up from 128m) and 2g (same as prior, 2048m, just different notation) and can be overridden in a number of ways but for example:

$ XNAT_MAX_HEAP=4g docker-compose up --detach

@pvannierop
Copy link
Author

Aaah what a rookie mistake! I forgot to re-build Docker images after reset to HEAD of origin :) Thousand apologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants