structurizr / lite

Structurizr Lite
https://docs.structurizr.com/lite
MIT License
226 stars 26 forks source link

Fixing some URLs for hosting structurizr-lite behind a reverse proxy #43

Closed janosmagyar closed 1 year ago

simonbrowndotje commented 1 year ago

You're likely going to run into other problems running Structurizr Lite behind a reverse-proxy because cdnUrl is used in a number of other places. Did you try the steps outlined in https://structurizr.com/share/76352/documentation#troubleshooting first?

janosmagyar commented 1 year ago

Yes.
There are other problems, especially running it under some folder like this:

server {
    listen       8888;
    server_name  someservername;
    location /somedirectory {
        proxy_pass         http://structurizr-lite:8080;
    }
}

Becase then I ran in to some errors with the authorization token, and some other links like <a href="/workspace/diagrams">Diagrams</a>.

So this was just fixing some easy ones, which probably usefull in the main branch as well.

The others I'm thinking how to solve without causing some troubles in other environments.

simonbrowndotje commented 1 year ago

It's not designed to run underneath a folder I'm afraid, only at /.

janosmagyar commented 1 year ago

I've tried to make it run, but it leads to some other repositories like UI and which using UI.

In this repo the back-end runs quite ok if I set the contextPath for the application something like this:

        Configuration.getInstance().setDataDirectory(structurizrDataDirectory);

        System.setProperty("server.servlet.context-path", Configuration.getInstance().getContextPath());

        SpringApplication.run(StructurizrLite.class, args);
        start();

It needs an extra setting in structurizr.properties like: structurizr.contextPath=/somedirectory. But then embedding not working, so in the UI should change in /src/js/structurizr-content.js like this:

structurizr.ui.ContentRenderer = function(workspace, host, urlPrefix, urlSuffix, safeMode, contextPath) {

...

            } else {
                // embed the specified diagram
                var id = 'structurizrEmbed' + (++embedIndex);
                var embedUrl = contextPath + '/embed' + '?workspace=' + workspace.id + '&view=' + encodeURIComponent(diagramIdentifier) + '&perspective=' + encodeURIComponent(perspective) + '&type=' + type + '&iframe=' + id + '&urlPrefix=' + urlPrefix + '&urlSuffix=' + encodeURIComponent(urlSuffix);

                return '<div style="text-align: center"><iframe id="' + id + '" class="structurizrEmbed thumbnail" src="' + embedUrl + '" width="100%" height="' + (window.innerHeight * MAX_HEIGHT_PERCENTAGE) + 'px" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" allowfullscreen="true"></iframe>' + '</div>';
            }

But this is a breaking change, so all others should be updated. ... and then coming the fixes for all the links...

So I understand if this is not a priority for this app at all.

simonbrowndotje commented 1 year ago

So I understand if this is not a priority for this app at all.

It's not I'm afraid, sorry!