Skip to content

Prevent unauthorized access to staging environment #349

@cemunds

Description

@cemunds

I was looking into ways to prevent my staging environment from being listed on Google. I found out that the easiest way to do this apparently is to use traefik's BasicAuth middleware and require a user name and password for the staging environment. I really like the easy setup in this repository, having only one docker-compose file that I can use to deploy to production and staging. However, I am having trouble coming up with a clean way to integrate BasicAuth only for staging.

My domains and stack names have the following pattern:
Staging

  • Domain: staging.xxx.com
  • Stack Name: xxx-stag

Production

  • Domain: xxx.com
  • Stack Name: xxx-prod

However, these are specified in the .gitlab-ci.yml and only injected during the deployment phase of the CI/CD pipeline.

How would I achieve this in a clean way, ideally reusing the variables from the .env file and not hard coding any stack name for the staging stack into the docker-compose file?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions