question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sourceIP missing with ALB?

See original GitHub issue

We’ve got a fairly generic ALB -> Lambda config and are seeing the following issue. sourceIp is not defined on event.requestContext.identity (or rather identity is not defined).

{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "TypeError: Cannot read property 'sourceIp' of undefined",
    "reason": {
        "errorType": "TypeError",
        "errorMessage": "Cannot read property 'sourceIp' of undefined",
        "stack": [
            "TypeError: Cannot read property 'sourceIp' of undefined",
            "    at getRequestValuesFromEvent (/var/task/api/_dist/node_modules/@vendia/serverless-express/src/event-sources/utils.js:52:50)",

Usage is as follows (app is in a Promise so we need to await it and then proxy it?):

module.exports.handler = async (event, context, callback): Promise<any> => {
    console.debug('index.handler: running');
    console.debug(` event: ${util.inspect(event)}`);
    console.debug(` context: ${util.inspect(context)}`);

    // Start a server (if one doesn't exist), then memoize it.
    if (!_server) {
        console.debug('index.handler: creating AWSServerlessExpress');
        const app = await __setup();
        _server = configure({ app, binaryMimeTypes });
        dog_log('api', 'boot', 'complete');
    }

    return _server.proxy({ event, context, callback });
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
alsonkempcommented, Jan 8, 2021

4.0.0-rc2

"dependencies": {
    "@vendia/serverless-express": "4.0.0-rc.2",

Hi Alison, are you running on V3 or V4 (just published an RC for that to the @vendia/serverless-express npm package). If it’s not working on V4 I’ll take a look (or you can send a PR if you discover a problem). We don’t plan on publishing anything but bug fixes to V3 (which doesn’t natively support ALB though people have hacked around it)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

0reactions
alsonkempcommented, Jan 28, 2021

Deny: agreed… If I knew what to deny. I didn’t feel like binary searching with 5 minute latencies…

I think it was a partial download header which was sent by express-static. ‘accept-ranges: bytes’ but I couldn’t find any documentation and AWS Support was unenthusiastic.

I went with a white list not only because I didn’t want to fiddle with identifying the bad header but also because I didn’t want to accidentally discover new ones and I didn’t mind controlling which headers are sent (it’s a pretty standard, static list).

I may have mentioned this already but besides copying your code, I did next to nothing to verify query string functionality.

On Thu, Jan 28, 2021, 3:58 AM Brett Andrews notifications@github.com wrote:

@alsonkemp https://github.com/alsonkemp what headers were causing you issue? I’d rather go with a deny list over an allow list.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vendia/serverless-express/issues/331#issuecomment-769005099, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIPBO4XB6EY6ZLYVG3GT3S4FGMTANCNFSM4V247DQA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Capture client IP addresses in the web server logs behind an ...
I'm using Elastic Load Balancing (ELB) for my web server, and I can see my load balancer's IP address in the web server...
Read more >
Missing Global Accelerator source IPs? - AWS re:Post
Starting today, your applications running on Application Load Balancers (ALB) fronted by AWS Global Accelerator can see the original source IP address of ......
Read more >
AWS Pass traffic from NLB to an ALB? - Stack Overflow
It is lost when the traffic goes through the NLB, because NLBs ... ALB (or the ALB itself) will always see the source...
Read more >
How do I find the load balancer's IP address used ... - YouTube
AWS Static LB - Integration of NLB with ALB || Concept- Use Case || Demo. Cloud4DevOps. Cloud4DevOps. •. •. 3.9K views 11 months...
Read more >
Support ALB advanced request routing · Issue #8126 - GitHub
Query string (new); Source IP (new). Additionally, each condition can now accept multiple values. New or Affected Resource(s).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found