fusionauth-containers icon indicating copy to clipboard operation
fusionauth-containers copied to clipboard

Reverse Proxy Not Working

Open narayanpromax opened this issue 3 years ago • 5 comments

Reverse proxying via caddy doesn't work. It gives 502

CaddyFile Content As below

# replace :80 with your domain name to get automatic https via LetsEncrypt
https://<your_domain> {
  reverse_proxy fusionauth:9011
}
  1. fusionauth is service running in docker
  2. caddy is running as service running in docker with above CaddyFile

narayanpromax avatar Dec 16 '20 17:12 narayanpromax

This issue/PR may be worth reviewing, as I think @atakane got this working: https://github.com/FusionAuth/fusionauth-containers/pull/61

mooreds avatar Dec 16 '20 22:12 mooreds

Reverse proxying via caddy doesn't work. It gives 502

CaddyFile Content As below


# replace :80 with your domain name to get automatic https via LetsEncrypt

https://<your_domain> {

  reverse_proxy fusionauth:9011

}

  1. fusionauth is service running in docker

  2. caddy is running as service running in docker with above CaddyFile

did you try without the protocol? Caddy wants us to write domain like auth.mydomain.com rather than https://auth.mydomain.com

atakane avatar Dec 16 '20 22:12 atakane

Yes, i tried.

Actually i copied hasura's caddy part for CaddyFile and docker and replaced necessary params on a different server.

https works in hasura but i tried both before posting here.

Even ip gives 502. Only accessing via :9011 working for now

narayanpromax avatar Dec 17 '20 03:12 narayanpromax

Hi, did you find a solution for this?

allochi avatar Jan 12 '21 16:01 allochi

My solution to this challenge, I used docker for everything, hope it works for others. Unfortunately I wasn't able to use DigitalOcean managed database, I always get connection error, but this is another story.

docker-compose.yml

version: "3"

services:
  http:
    image: caddy:latest
    container_name: http
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    networks:
      - network
    volumes:
      - $PWD/Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

  db:
    image: postgres:11.9-alpine
    container_name: db
    environment:
      PGDATA: /var/lib/postgresql/data/pgdata
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    networks:
      - network
    restart: unless-stopped
    volumes:
      - db_data:/var/lib/postgresql/data

  fusionauth:
    image: fusionauth/fusionauth-app:latest
    container_name: fusionauth
    depends_on:
      - db
      - http
    environment:
      DATABASE_URL: ${DATABASE_URL}
      DATABASE_ROOT_USERNAME: ${POSTGRES_USER}
      DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      FUSIONAUTH_APP_MEMORY: ${FUSIONAUTH_APP_MEMORY}
      FUSIONAUTH_APP_RUNTIME_MODE: production
      SEARCH_TYPE: database
    networks:
      - network
    restart: unless-stopped
    volumes:
      - fa_config:/usr/local/fusionauth/config

networks:
  network:

volumes:
  db_data:
  fa_config:
  caddy_data:
  caddy_config:

Caddyfile

auth.my-domain.com {
	reverse_proxy fusionauth:9011
}

allochi avatar Jan 12 '21 21:01 allochi

The solution to the problem is network.

I read line by line with @allochi's solution and found this one thing extra

Do take care that caddy and fusionauth are on same network

narayanpromax avatar Apr 07 '24 13:04 narayanpromax

@narayanpromax thanks so much for closing the issue after you found a solution.

mooreds avatar Apr 08 '24 11:04 mooreds