ONLYOFFICE / DocumentServer

ONLYOFFICE Docs is a free collaborative online office suite comprising viewers and editors for texts, spreadsheets and presentations, forms and PDF, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
https://www.onlyoffice.com
GNU Affero General Public License v3.0
4.92k stars 1.1k forks source link

Cache/Printfile ignores X-Forwarded-Host #1653

Open lublak opened 2 years ago

lublak commented 2 years ago

Do you want to request a feature or report a bug?

bug

What is the current behavior?

currently i am trying to bind onlyoffice to a virtual path. Based on: https://github.com/ONLYOFFICE/document-server-proxy/blob/master/nginx/proxy-to-virtual-path.conf I have tried the following:

import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';

const app = express();

app.use(createProxyMiddleware('/onlyoffice', {
    target: 'http://localhost/',
    changeOrigin: false,
    ws: true,
    pathRewrite: {
        '^/onlyoffice': ''
    },
    xfwd: false,
    onProxyReq: (proxyReq, req, res) => {
        proxyReq.setHeader('X-Forwarded-Host', 'localhost:8090/onlyoffice');
        proxyReq.setHeader('X-Forwarded-Proto', 'http');
    },
    logLevel: 'debug'
}));

app.listen(8090);

everything works and is reachable. But the cache ignores the path: http://localhost:8090/cache/files/000000000000/Editor.bin/Editor.bin?md5=**********&expires=1648294397&filename=Editor.bin instead of http://localhost:8090/onlyoffice/cache/files/000000000000/Editor.bin/Editor.bin?md5=**********&expires=1648294397&filename=Editor.bin

same for the printfile path.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

Just use the code above. It should be completely executable except for the problem with Editor.bin

When i add this it works (which of course is not the solution because the /cache path is different from /onlyoffice/cache):

app.use(createProxyMiddleware('/cache', {
    target: 'http://localhost',
}));
app.use(createProxyMiddleware('/printfile', {
    target: 'http://localhost',
}));

What is the expected behavior?

The cache should also use X-Forwarded-Host.

Did this work in previous versions of DocumentServer?

Not tested

DocumentServer version:

7.0.1

Operating System:

Windows 10

Browser version:

Firefox 98.0b8

More: grafik grafik

igwyd commented 5 months ago

Hello @lublak, sorry for the late reply, but we don't have proxy example for the express library.