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

Reverse Proxy Not Working #65

Closed
narayanpromax opened this issue Dec 16, 2020 · 7 comments
Closed

Reverse Proxy Not Working #65

narayanpromax opened this issue Dec 16, 2020 · 7 comments

Comments

@narayanpromax
Copy link

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 narayanpromax changed the title Reverse Proxy Reverse Proxy Not Working Dec 16, 2020
@mooreds
Copy link
Contributor

mooreds commented Dec 16, 2020

This issue/PR may be worth reviewing, as I think @atakane got this working: #61

@atakane
Copy link

atakane commented Dec 16, 2020

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

@narayanpromax
Copy link
Author

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

@allochi
Copy link

allochi commented Jan 12, 2021

Hi, did you find a solution for this?

@allochi
Copy link

allochi commented Jan 12, 2021

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
}

@narayanpromax
Copy link
Author

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

@mooreds
Copy link
Contributor

mooreds commented Apr 8, 2024

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

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

4 participants