Content
You are here:
Docker-Compose behind NGINX Reverse Proxy (Docker Version)
Added by Office netMedia over 1 year ago
Hi Folks,
it is kind of funny there is another Thread with the same name https://community.openproject.org/topics/16586 but still the problem is different i guess.
I have a NGINX Reverse Proxy running via Docker and already have many services on this reverse proxy (nextcloud, gitea, etc).
Now i want to add openproject as well. I adjusted the docker-compose.yml file
networks:
...
nginx_proxy:
external: true
...
services:
...
[removed proxy service]
...
web:
<<: *app
command: "./docker/prod/web"
networks:
- frontend
- backend
- nginx_proxy #new
# new
environment:
- TZ=${TIMEZONE}
- VIRTUAL_HOST=${DOMAIN}
- VIRTUAL_PORT=8080
- LETSENCRYPT_HOST=${DOMAIN}
- LETSENCRYPT_EMAIL=${MY_LETSENCRYPT_EMAIL}
depends_on:
- db
- cache
- seeder
labels:
- autoheal=true
The problem is the web
service cannot connect to the database:
compose-web-1 | => Booting Puma
compose-web-1 | => Rails 7.0.4.2 application starting in production
compose-web-1 | => Run `bin/rails server --help` for more startup options
compose-web-1 | Exiting
compose-web-1 | /app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.2/lib/active_record/connection_adapters/postgresql_adapter.rb:87:in `rescue in new_client': connection to server at "127.0.0.1", port 5432 failed: Connection refused (ActiveRecord::ConnectionNotEstablished)
compose-web-1 | Is the server running on that host and accepting TCP/IP connections?
2 things i dont get:
- why the web service need access to the db anyway? this should be handeld by the
app
service right? - and the other thing: the db is available at
db
and not127.0.0.1
right? how do i change it?
here is my .env file:
TAG=12
HTTPS=true
OPENPROJECT_HOST__NAME=project.example.com
DOMAIN=project.example.com
TIMEZONE=Europe/Vienna
MY_LETSENCRYPT_EMAIL=office@example.com
#PORT=127.0.0.1:8080
PORT=8080
OPENPROJECT_RAILS__RELATIVE__URL__ROOT=
IMAP_ENABLED=false
DATABASE_URL="postgres://postgres:myPassword@db/openproject?pool=20&encoding=unicode&reconnect=true"
POSTGRES_PASSWORD=myPassword
RAILS_MIN_THREADS=4
RAILS_MAX_THREADS=16
#PGDATA="/var/lib/postgresql/data"
#OPDATA="/var/openproject/assets"
(offtopic: i need to use the markdown source editor because the WYSIWYG Editor does not respond to backspace and blocks randomly..)
Replies (1)
it works now.
if you set any environment variables for
web
service you need to also pass the database_url environment variable!