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

Docker Compose NGINX targeting wrong port #222

Closed
Sam-tesouro opened this issue Jun 18, 2024 · 3 comments
Closed

Docker Compose NGINX targeting wrong port #222

Sam-tesouro opened this issue Jun 18, 2024 · 3 comments
Assignees

Comments

@Sam-tesouro
Copy link

Describe the bug

Dotnet 8 brought the default container port to 8080 from 80, this port needs to be added as a VIRUAL_PORT=8080 env var to the dotnet deployments in docker compose. With this change the nginx proxy knows which port to target!

To Reproduce

docker compose up

docker-compose.yml file with relevant fix

version: '3.4'
services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - '/var/run/docker.sock:/tmp/docker.sock:ro'
      - './shared/nginx/vhost.d:/etc/nginx/vhost.d'
      - './shared/nginx/certs:/etc/nginx/certs:ro'
    networks:
      proxy: null
      identityserverui:
        aliases:
          - sts.skoruba.local
          - admin.skoruba.local
          - admin-api.skoruba.local
    restart: always
  skoruba.duende.identityserver.admin:
    image: '${DOCKER_REGISTRY-}skoruba-duende-identityserver-admin'
    build:
      context: .
      dockerfile: src/Skoruba.Duende.IdentityServer.Admin/Dockerfile
    container_name: skoruba-duende-identityserver-admin
    environment:
      - VIRTUAL_PORT=8080
      - VIRTUAL_HOST=admin.skoruba.local
      - 'ConnectionStrings__ConfigurationDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__PersistedGrantDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__IdentityDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__AdminLogDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__AdminAuditLogDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__DataProtectionDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'AdminConfiguration__IdentityAdminBaseUrl=https://admin.skoruba.local'
      - 'AdminConfiguration__IdentityAdminRedirectUri=https://admin.skoruba.local/signin-oidc'
      - 'AdminConfiguration__IdentityServerBaseUrl=https://sts.skoruba.local'
      - AdminConfiguration__RequireHttpsMetadata=false
      - 'IdentityServerData__Clients__0__ClientUri=https://admin.skoruba.local'
      - 'IdentityServerData__Clients__0__RedirectUris__0=https://admin.skoruba.local/signin-oidc'
      - 'IdentityServerData__Clients__0__FrontChannelLogoutUri=https://admin.skoruba.local/signin-oidc'
      - 'IdentityServerData__Clients__0__PostLogoutRedirectUris__0=https://admin.skoruba.local/signout-callback-oidc'
      - 'IdentityServerData__Clients__0__AllowedCorsOrigins__0=https://admin.skoruba.local'
      - 'IdentityServerData__Clients__1__RedirectUris__0=https://admin-api.skoruba.local/swagger/oauth2-redirect.html'
      - 'Serilog__WriteTo__1__Args__connectionString=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - DockerConfiguration__UpdateCaCertificate=true
      - ASPNETCORE_ENVIRONMENT=Development
    command: dotnet Skoruba.Duende.IdentityServer.Admin.dll /seed
    depends_on:
      - db
      - skoruba.duende.identityserver.sts.identity
    volumes:
      - './shared/serilog.json:/app/serilog.json'
      - './shared/identitydata.json:/app/identitydata.json'
      - './shared/identityserverdata.json:/app/identityserverdata.json'
      - './shared/nginx/certs/cacerts.crt:/usr/local/share/ca-certificates/cacerts.crt'
    networks:
      identityserverui: null
  skoruba.duende.identityserver.admin.api:
    image: '${DOCKER_REGISTRY-}skoruba-duende-identityserver-admin-api'
    build:
      context: .
      dockerfile: src/Skoruba.Duende.IdentityServer.Admin.Api/Dockerfile
    container_name: skoruba-duende-identityserver-admin-api
    environment:
      - VIRTUAL_PORT=8080
      - VIRTUAL_HOST=admin-api.skoruba.local
      - AdminApiConfiguration__RequireHttpsMetadata=false
      - 'AdminApiConfiguration__ApiBaseUrl=https://admin-api.skoruba.local'
      - 'AdminApiConfiguration__IdentityServerBaseUrl=https://sts.skoruba.local'
      - 'ConnectionStrings__ConfigurationDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__PersistedGrantDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__IdentityDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__AdminLogDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__AdminAuditLogDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__DataProtectionDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - DockerConfiguration__UpdateCaCertificate=true
      - ASPNETCORE_ENVIRONMENT=Development
    volumes:
      - './shared/serilog.json:/app/serilog.json'
      - './shared/nginx/certs/cacerts.crt:/usr/local/share/ca-certificates/cacerts.crt'
    networks:
      identityserverui: null
  skoruba.duende.identityserver.sts.identity:
    image: '${DOCKER_REGISTRY-}skoruba-duende-identityserver-sts-identity'
    build:
      context: .
      dockerfile: src/Skoruba.Duende.IdentityServer.STS.Identity/Dockerfile
    container_name: skoruba-duende-identityserver-sts-identity
    environment:
      - VIRTUAL_PORT=8080
      - VIRTUAL_HOST=sts.skoruba.local
      - 'ConnectionStrings__ConfigurationDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__PersistedGrantDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__IdentityDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'ConnectionStrings__DataProtectionDbConnection=Server=db;Database=IdentityServerAdmin;User Id=sa;Password=${DB_PASSWORD:-Password_123};MultipleActiveResultSets=true'
      - 'AdminConfiguration__IdentityAdminBaseUrl=https://admin.skoruba.local'
      - 'IdentityServerOptions__IssuerUri=https://sts.skoruba.local'
      - IdentityServerOptions__KeyManagement__Enabled=true
      - IdentityServerOptions__Events__RaiseErrorEvents=true
      - IdentityServerOptions__Events__RaiseInformationEvents=true
      - IdentityServerOptions__Events__RaiseFailureEvents=true
      - IdentityServerOptions__Events__RaiseSuccessEvents=true
      - DockerConfiguration__UpdateCaCertificate=true
      - ASPNETCORE_ENVIRONMENT=Development
    depends_on:
      - db
    volumes:
      - './shared/serilog.json:/app/serilog.json'
      - './shared/nginx/certs/cacerts.crt:/usr/local/share/ca-certificates/cacerts.crt'
    networks:
      identityserverui:
        aliases:
          - sts.skoruba.local
  db:
    image: 'mcr.microsoft.com/mssql/server:2017-CU20-ubuntu-16.04'
    ports:
      - '7900:1433'
    container_name: skoruba-duende-identityserver-db
    environment:
      SA_PASSWORD: '${DB_PASSWORD:-Password_123}'
      ACCEPT_EULA: 'Y'
    volumes:
      - 'dbdata:/var/opt/mssql'
    networks:
      identityserverui: null
volumes:
  dbdata:
    driver: local
networks:
  proxy:
    driver: bridge
  identityserverui:
    driver: bridge
@skoruba
Copy link
Owner

skoruba commented Jun 19, 2024

Hi @Sam-tesouro - thank you for reporting this issue, could you please send a PR?

thanks!

@apetrut apetrut mentioned this issue Sep 19, 2024
@skoruba
Copy link
Owner

skoruba commented Sep 25, 2024

I will fix it in 2.4.0. release. thanks!

@skoruba skoruba mentioned this issue Sep 28, 2024
6 tasks
@skoruba
Copy link
Owner

skoruba commented Sep 29, 2024

Released in 2.4.0.
Thanks!

@skoruba skoruba closed this as completed Sep 29, 2024
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