Skip to content

Keep proxy IP rather than original caller IP #556

@cawecoy

Description

@cawecoy

Hello, thanks for the amazing work here!

I'm using an API that requires a static IP, which the original caller can't have for now. That's why I'm creating a proxy using this package.

My script so far:

const express = require('express');
const proxy = require('express-http-proxy');
require('dotenv').config();

const api_domain = process.env.API_DOMAIN;
const proxy_ip = process.env.PROXY_IP;

const app = express();

app.use('/', proxy(`https://${api_domain}`, {
    proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
        proxyReqOpts.headers['X-Forwarded-For'] = proxy_ip;
        proxyReqOpts.headers['X-Real-IP'] = proxy_ip;
        proxyReqOpts.headers['Client-IP'] = proxy_ip;
        return proxyReqOpts;
    }
}));

app.listen(3000, () => {
    console.log('Proxy server listening on port 3000');
});

But the API is seeing the original caller IP, not the proxy IP... Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions