ONLYOFFICE 7.0: online forms, password protection in sheets, collaboration improvements and much more
ONLYOFFICE 7.0 released

Proxy Onlyoffice to traefik server

Hi there,
I have a webserver A running apache and exposed to the external world (ports 80/443) and a server B (IP running onlyoffice and traefik both as docker. I have a domain name for onlyoffice that points to A and I would like to proxy that request to server B, where Onlyoffice runs under traefik. Everything’s ok using unencrypted connection to port 80. Problems arise with SSL, as I get 404 error.
Here is my apache configuration file:

<IfModule mod_ssl.c>
  <VirtualHost *:443>


LoadModule authn_core_module modules/
LoadModule authz_core_module modules/
LoadModule proxy_module modules/
LoadModule proxy_http_module modules/
LoadModule headers_module modules/
LoadModule setenvif_module modules/
LoadModule ssl_module modules/

SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/

## Strong SSL Security

SSLProtocol All -SSLv2 -SSLv3
SSLCompression off
SSLHonorCipherOrder on

SetEnvIf Host "^(.*)$" THE_HOST=$1
RequestHeader setifempty X-Forwarded-Proto https
RequestHeader setifempty X-Forwarded-Host %{THE_HOST}e
ProxyAddHeaders Off

ProxyPass / ""
ProxyPassReverse / ""

LogLevel error proxy:trace5
  #  LogLevel error
    ErrorLog /mypath/onlyoffice_apache_error.log
    CustomLog /mypath/onlyoffice_apache_access.log combined


Here is my onlyoffice docker-compose file:

version: '3.7'
    container_name: onlyoffice
    image: onlyoffice/documentserver:latest
      - traefik
    stdin_open: true
    tty: true
    restart: always
      - "traefik.enable=true"
      - "traefik.http.routers.onlyoffice.rule=Host(``)"
      - "traefik.http.routers.onlyoffice.entrypoints=web"
      - "traefik.http.routers.onlyoffice.middlewares=onlyoffice-headers"
      - ""

      ## Middleware definition
      # Headers for onlyoffice,
      - "traefik.http.middlewares.onlyoffice-headers.headers.customrequestheaders.X-Forwarded-Proto=http"
      - "traefik.http.middlewares.onlyoffice-headers.headers.accesscontrolalloworiginlist=*"
      - /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data
      - /app/onlyoffice/DocumentServer/log:/var/log/onlyoffice
      - /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice
      - /app/onlyoffice/DocumentServer/db:/var/lib/postgresql

    external: true

Thank you in advance to whom may help.

Hello @Jack
Could you please run a test? Please change X-Forwarded-Proto header from ‘http’ to ‘https’ in Traefik config file.
By the way, try to add this header:

  • “traefik.http.routers.onlyoffice-documentserver.middlewares=onlyoffice-headers”

I did as you said, but now I get Service error.

Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.38 (Raspbian) Server at mydomain Port 443

Hello @Jack
Sorry for the late reply. We tried to reproduce the situation with your provided configs. But we are stuck at the moment.
Could you please provide us with your Traefik config files.

Here they are:

  insecure = true
    address = ":80"
#    [entryPoints.web.http.redirections.entryPoint]
#      to = "websecure"
#      scheme = "https"

    address = ":443"

  email = ""
  storage = "acme.json"
    entryPoint = "web"

  watch = true
  exposedByDefault = false
  network = "traefik"

  filename = "/etc/traefik/traefik_dynamic.toml"


  rule = "Host(`myhost.local`)"
  entrypoints = ["web"]
  service = "api@internal"

How exactly did you check the SSL issue? I mean, did you check it by domain name or IP address from your local network? Or you checked it from ‘outside’ through your Apache server via http?

I am not sure I correctly got what you mean. I obtained SSL certificate on server A running certbot from CLI. Tried to get OO via browser using domain name ( and got the above mentioned HTTP 404 error. It is as if it could not find the right output path on OO server B.

Could you please run a test? Change these lines in your Apache config files:

ProxyPass / ""
ProxyPassReverse / ""

to domain names instead of ip addresses. Will the issue change?

The issue now says: “ERR_TOO_MANY_REDIRECTS”

It looks like redirect loop. Please follow my steps (but prepare whole server backup first):

Change this line in Traefik config line:




Or try to resolve it via DNS. You have to add some A-record like this: - traefik.onlyoffice.

So both servers will know that such IP address has that name.

Also go to Apache config file and set the name:

ProxyPass / "http://traefik.onlyoffice/"

ProxyPassReverse / "http://traefik.onlyoffice/"

But I’m a little bit confused by your settings. I mean that I don’t understand why you use Traefik. You can remove Traefik and there will be no issues. Or remove Apache and use Traefik only.

What is your final goal of Traefik usage?

By the way, just crossed my mind, there’s a good title about Traefik configuration: How To Use Traefik v2 as a Reverse Proxy for Docker Containers on Ubuntu 20.04 | DigitalOcean

Please take a look at it, I hope it will be useful.