scale8 / scale8-tag-manager-and-analytics

Website analytics, JavaScript error tracking + analytics, tag manager, data ingest endpoint creation (tracking pixels). GDPR + CCPA compliant.
https://scale8.com
GNU Affero General Public License v3.0
302 stars 17 forks source link

Self-hosted version provides http src as `127.0.0.1:3000` #109

Closed BackedUpBooty closed 2 years ago

BackedUpBooty commented 2 years ago

Describe the bug I created a reverse proxy to access the gui via my sub.domain.com. The documentation I found doesn't really give info for this, however the tags being generated for applications still show src=http://127.0.0.1:3000/edge/xxxxxxxxxxxxxxxxxxx. I have tried changing the PROXY_LOCATION and the S8_EDGE_SERVER to my sub.domain.com but the generated tags still show the src listed above.

How do we change the tag so that it will work via reverse proxy? Doing it manually doesn't seem to work

To Reproduce Steps to reproduce the behavior:

  1. Create service via docker-compose (including trying to use https://mysub.domain.com as proxy location and edge server)
  2. Create reverse proxy to access via 'mysub.domain.com`
  3. Create User
  4. Log in
  5. Create application
  6. View generated tag

Expected behavior Generated tag would follow a template which allowed for reverse proxies, something like:

Additional context Hardware

cwbeck commented 2 years ago

@BackedUpBooty thank you for the bug report.

Just to clarify that you are using a load balancer to terminate SSL and then proxy that on? Are you doing it all via docker-compose locally?

We'll investigate using the steps you have provided and update this thread with configuration steps or push a fix.

BackedUpBooty commented 2 years ago

Hey thanks for the quick reply.

I only have the one server which both the proxy and scale8 services are running on.

Proxy is a pre-existing SWAG docker container (essentially nginx + LE certificate host) which is pointing at the router container (which I guess is an nginx container itself at the end of the day).

Yes everything is being run via docker-compose locally.

cwbeck commented 2 years ago

Awesome, thank you for the extra info. We'll replicate your setup and get this sorted for you.

cwbeck commented 2 years ago

@BackedUpBooty - I have updated docker-compose.yml to reflect the router setting requirement.

https://github.com/scale8/scale8/pull/111

api:
        image: scale8/api:latest
        container_name: api
        depends_on:
            - mongodb
        expose:
            - "8082"
        environment:
            # To connect to a local version of MongoDB, use mongodb://host.docker.internal .
            MONGO_CONNECT_STRING: "mongodb://mongodb"
            # When booting, we want the server to run the setup job (this will race if multiple API servers are booted at the same time)
            SETUP_MODE: "true"
            # The UI server...
            S8_UI_SERVER: "http://127.0.0.1:8080"

If you change S8_UI_SERVER to https://mysub.domain.com that will make sure the generated tag is correct.

edge:
        image: scale8/edge:latest
        container_name: edge
        depends_on:
            - mongodb
        expose:
            - "6080"
        environment:
            # Run in production
            S8_ENV: "production"
            # To connect to a local version of MongoDB, use mongodb://host.docker.internal .
            MONGO_CONNECT_STRING: "mongodb://mongodb"
            # The API server - required for generating live previews. Here we refer to the 'api' server as defined below.
            S8_API_SERVER: "http://api:8082"
            # The root server refers to the entry point of the network. In this example, we are using the 'route' defined below.
            S8_EDGE_SERVER: "http://127.0.0.1:8080"
            # Proxy a platform's live build in. PROXY_FOR can be either be 'core' or the platform id associated with the platform.
            # PROXY_FOR: "core"
            # PROXY_LOCATION: "http://host.docker.internal:3124/main.js"

Then in the edge config, change S8_EDGE_SERVER to https://mysub.domain.com.

PROXY_LOCATION is purely for debugging and creating platforms. You don't need to change it.

Please let me know if you have any other issues.

BackedUpBooty commented 2 years ago

Hey thanks very much, that did it! I'll close the ticket now, thanks for such a speedy fix. Looking forward to playing around with this now.