Docker-DocumentServer icon indicating copy to clipboard operation
Docker-DocumentServer copied to clipboard

js path missing on page load,Second-level domain name lost

Open nomatterfine opened this issue 3 years ago • 6 comments
trafficstars

api.js is loaded through vue like this https://idemo.com/onlineEditor/web-apps/apps/api/documents/api.js image

The final access address is https://10.16.11.11:9000/web-apps/apps/api/documents/api.js

The relationship of domain name mapping is idemo.com/onlineEditor/onlineEditor --->10.16.11.11:9000

But when loading https://idemo.com/onlineEditor/web-apps/apps/documenteditor/main/index.html, directly switch to https://idemo.com/7.1.1-23/web -apps/apps/documenteditor/main/index.html

Second-level domain name lost ! /onlineEditor lost ! The address required here is https://idemo.com/onlineEditor/7.1.1-23/web -apps/apps/documenteditor/main/index.html

image

image

I started it through docker, how should I configure to keep this second-level domain name so that the second-level domain name is not lost

nomatterfine avatar Jul 04 '22 07:07 nomatterfine

Hi, not sure but I think DocumentServer docker is not designed that way so it can be part of subdomain

In that case you should manually setup nginx and forward https://idemo.com/onlineEditor/web-apps/apps/documenteditor/main/index.html to https://10.16.11.11:9000/web-apps/apps/api/documents/api.js

ShockwaveNN avatar Jul 04 '22 07:07 ShockwaveNN

Hi, not sure but I think DocumentServer docker is not designed that way so it can be part of subdomain

In that case you should manually setup nginx and forward https://idemo.com/onlineEditor/web-apps/apps/documenteditor/main/index.html to https://10.16.11.11:9000/web-apps/apps/api/documents/api.js

This path **https://idemo.com/onlineEditor/web-apps**/apps/documenteditor/main/index.html will redirect to https:/**/idemo.com/7.1.1-23**/web-apps/apps/documenteditor /main/index.html,

the second-level domain name onlineEditor is lost!!

nomatterfine avatar Jul 04 '22 08:07 nomatterfine

@igwyd Pleas take a look, if ever had experience with such configurations

ShockwaveNN avatar Jul 04 '22 08:07 ShockwaveNN

Hello @nomatterfine, it's https://idemo.com/onlineEditor/ this isn't called a second-level domain, but a subfolder. Your problem with your proxy setting i think. We don't have approved configs for proxying documentserver to the subfolder, but i cheked my nginx custom configuration and it is work. My nginx config:

# Example for use the document server at subfolder.
# Replace {{SSL_CERTIFICATE_PATH}} with the path to the ssl certificate file
# Replace {{SSL_KEY_PATH}} with the path to the ssl private key file
# Replace {{SERVER_NAME}} with the domain name 
# Replace {{DOCUMENTSERVER_ADDRESS}} with the backend server address


map $http_x_forwarded_proto $the_scheme {
    default $http_x_forwarded_proto;
    "" $scheme;
}

map $http_x_forwarded_host $the_host {
    default $http_x_forwarded_host;
    "" $host;
}

map $http_upgrade $proxy_connection {
    default upgrade;
    "" close;
}

server {
        listen 80;
        server_name {{SERVER_NAME}};
        rewrite ^ https://$http_host$request_uri? permanent;
        server_tokens off;
}

server {
        listen 443 http2;
        ssl on;
        ssl_certificate {{SSL_CERTIFICATE_PATH}};
        ssl_certificate_key {{SSL_KEY_PATH}};
        server_name {{SERVER_NAME}};
        proxy_set_header X-Forwarded-For $remote_addr;
        server_tokens off;

    location /onlyoffice/ {
        proxy_pass https://{{DOCUMENTSERVER_ADDRESS}}/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $proxy_connection;
        proxy_set_header X-Forwarded-Host $the_host/onlyoffice;
        proxy_set_header X-Forwarded-Proto $the_scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

I hope it help you.

igwyd avatar Jul 07 '22 14:07 igwyd

I'm also running into this issue. I believe something in the JS that makes the call to the root host instead of the proxy path.

after

Iframe path is getting the correct one from the getBasePath function which is basically getting the proxy path from the api.js script tag

Script tag with proxy path Iframe gets the correct proxy path
before after
function getBasePath() {
        var scripts = document.getElementsByTagName('script'),
            match;

        for (var i = scripts.length - 1; i >= 0; i--) {
            match = scripts[i].src.match(/(.*)api\/documents\/api.js/i);
            if (match) {
                return match[1];
            }
        }

        return "";
    }

call to the cache/file endpoint should use the same getBasePath function to resolve it correctly ?

iqbalhasnan avatar Jul 14 '22 05:07 iqbalhasnan

Hello @iqbalhasnan. I also think that you have the same problem as @nomatterfine. It's important that x-forwarded-proto and x-forwarded-host with virtual directory(subfolder) headers are sent or it can be specified in x-forwarded-prefix header.

igwyd avatar Jul 14 '22 08:07 igwyd

This issue was closed due to no response.

ShockwaveNN avatar Oct 21 '22 19:10 ShockwaveNN

if use subFolder or not port 80, the config should be like:

      location /onlyoffice/ {
        proxy_pass https://{{DOCUMENTSERVER_ADDRESS}}/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $proxy_connection;
        proxy_set_header X-Forwarded-Host $the_host:$server_port/onlyoffice;
        proxy_set_header X-Forwarded-Proto $the_scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

the onlyoffice is your subFolder, the server_port is your custom port.

imwower avatar Feb 04 '23 15:02 imwower