Skip to content

Attaching a refreshed certificate #308

Description

@denchen

Is this a question?

I asked this over on StackOverflow but haven't gotten a response

I'm using this library to create a proxy to a server that requires certificates (cert, ca, and key). The problem is, these certs expire over time, so I need to retrieve new certificates. However, I'm unsure how to attach a new certificate to an existing proxy.

My basic setup is similar to the following:

app.use(
  '/api',
  proxy({
    target: {
      protocol: 'https:',
      host: 'another.domain.com',
      port: 443,
      cert: cert,
      ca: ca_cert,
      key: key
    },
    secure: false,
    changeOrigin: true
  })
);

Is it possible to insert a middleware before the proxy() to retrieve new certs and have proxy() use the new certs? Something like

app.use(
  '/api',
  (req, res, next) => {
    if (/* cert has expired */) {
      cert = /* get new cert */
    }
  },
  proxy({
    target: {
      protocol: 'https:',
      host: 'another.domain.com',
      port: 443,
      cert: cert,
      ca: ca_cert,
      key: key
    },
    secure: false,
    changeOrigin: true
  })
);

Or will that not work? Can I use onProxyReq() to manipulate the certs? Or can I tear down the original proxy() instance and instantiate a new one?

Setup

  • http-proxy-middleware: 0.19.0
  • http-proxy-middleware configuration
  • server: [email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions