Uppy + Companion + Docker + Nginx

Hello. I’m trying to configure Uppy, Companion, Docker and Nginx.

When I’m trying to use companion URL provider on my web site, I see the following:
POST https://my-domain/companion/url/meta 404 (Not Found)

Root URL GET https://my-domain/companion works correctly. It looks like I don’t have companion urls.

Here is my nginx config:

location /companion {
    add_header 'Access-Control-Allow-Origin' 'https://my-domain' always;
    add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, OPTIONS, PATCH, HEAD';

    if ($request_method = 'OPTIONS') {
      add_header 'Access-Control-Allow-Origin' 'https://my-domain' always;
      add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, OPTIONS, PATCH, HEAD';
      add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,X-Mx-ReqToken,Access-Control-Allow-Origin,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Tus-Resumable,Upload-Length,Upload-Metadata,Upload-Offset,uppy-auth-token,uppy-versions';
      add_header 'Access-Control-Max-Age'        86400;
      add_header 'Access-Control-Allow-Credentials' 'true' always;
      add_header 'Content-Length' 0;
      add_header 'Content-Type' 'text/plain; charset=UTF-8';
      return 204;

    proxy_pass http://companion-server:3020/;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Host $http_host;
    proxy_redirect off;

Here is my index.js for companion server in the Docker container:

const express = require('express')
const bodyParser = require('body-parser')
const session = require('express-session')
const companion = require('@uppy/companion')
const url = require('@uppy/url')
const dropbox = require('@uppy/dropbox')
const { getRoutes } = require('get-routes')

const app = express()

  secret: process.env.APP_SECRET,
  resave: true,
  saveUninitialized: true

// Routes
app.get('/', (req, res) => {
  res.setHeader('Content-Type', 'text/plain')
  res.send('Welcome to Companion')

// initialize uppy
const uppyOptions = {
  providerOptions: {
    dropbox: {
      key: process.env.DROPBOX_KEY,
      secret: process.env.DROPBOX_SECRET
  server: {
    host: 'localhost:3020',
    protocol: 'http'
  filePath: './uploads',
  secret: process.env.UPPY_SECRET,
  debug: true


// handle 404
app.use((req, res, next) => {
  return res.status(404).json({ message: 'Not Found' })

// handle server errors
app.use((err, req, res, next) => {
  console.error('\x1b[31m', err.stack, '\x1b[0m')
  res.status(err.status || 500).json({ message: err.message, error: err })

const routes = getRoutes(app);
companion.socket(app.listen(3020), uppyOptions)

Give me a piece of advice, please.