[GH-ISSUE #456] js path missing on page load,Second-level domain name lost #228

Closed
opened 2026-02-26 10:31:10 +03:00 by kerem · 8 comments
Owner

Originally created by @nomatterfine on GitHub (Jul 4, 2022).
Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/456

Originally assigned to: @igwyd on GitHub.

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

Originally created by @nomatterfine on GitHub (Jul 4, 2022). Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/456 Originally assigned to: @igwyd on GitHub. api.js is loaded through vue like this https://idemo.com/onlineEditor/web-apps/apps/api/documents/api.js ![image](https://user-images.githubusercontent.com/90117583/177114709-1df7532b-da1d-4c11-b0db-ebb6006502ae.png) 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](https://user-images.githubusercontent.com/90117583/177107948-9ac4b688-9f05-4e46-adb8-faee8119a3a0.png) ![image](https://user-images.githubusercontent.com/90117583/177108033-eabfa2e2-124a-4b3c-8553-b41b2f64929c.png) 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
kerem closed this issue 2026-02-26 10:31:10 +03:00
Author
Owner

@ShockwaveNN commented on GitHub (Jul 4, 2022):

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

<!-- gh-comment-id:1173481805 --> @ShockwaveNN commented on GitHub (Jul 4, 2022): 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
Author
Owner

@nomatterfine commented on GitHub (Jul 4, 2022):

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!!

<!-- gh-comment-id:1173495710 --> @nomatterfine commented on GitHub (Jul 4, 2022): > 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****!!
Author
Owner

@ShockwaveNN commented on GitHub (Jul 4, 2022):

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

<!-- gh-comment-id:1173500810 --> @ShockwaveNN commented on GitHub (Jul 4, 2022): @igwyd Pleas take a look, if ever had experience with such configurations
Author
Owner

@igwyd commented on GitHub (Jul 7, 2022):

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.

<!-- gh-comment-id:1177673517 --> @igwyd commented on GitHub (Jul 7, 2022): 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.
Author
Owner

@iqbalhasnan commented on GitHub (Jul 14, 2022):

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 ?

<!-- gh-comment-id:1184006174 --> @iqbalhasnan commented on GitHub (Jul 14, 2022): 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. <table> <tr> <td> <img width="800" alt="after" src="https://user-images.githubusercontent.com/794601/178905786-c75dc433-93cc-4dc2-98b4-76491fa06dbf.png"> </td> </tr> </table> Iframe path is getting the correct one from the getBasePath function which is basically getting the proxy path from the api.js script tag <table> <tr> <th>Script tag with proxy path</th> <th>Iframe gets the correct proxy path</th> </tr> <tr> <td> <img width=“800” alt="before" src="https://user-images.githubusercontent.com/794601/178906419-e11b19ea-4fb8-482d-af49-ca3844d7dbfe.png"> </td> <td> <img width=“800” alt="after" src="https://user-images.githubusercontent.com/794601/178906010-3e9466b3-62dc-4016-afad-ed39a8532e2e.png"> </td> </tr> </table> ``` 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 ?
Author
Owner

@igwyd commented on GitHub (Jul 14, 2022):

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.

<!-- gh-comment-id:1184179220 --> @igwyd commented on GitHub (Jul 14, 2022): 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.
Author
Owner

@ShockwaveNN commented on GitHub (Oct 21, 2022):

This issue was closed due to no response.

<!-- gh-comment-id:1287340064 --> @ShockwaveNN commented on GitHub (Oct 21, 2022): This issue was closed due to no response.
Author
Owner

@imwower commented on GitHub (Feb 4, 2023):

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.

<!-- gh-comment-id:1416781396 --> @imwower commented on GitHub (Feb 4, 2023): 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Docker-DocumentServer-ONLYOFFICE#228
No description provided.