AWS API Gateway:是否可以在每种API方法中添加源IP地址? [英] AWS API Gateway: Is it possible to add source IP address in each API method?

查看:202
本文介绍了AWS API Gateway:是否可以在每种API方法中添加源IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用AWS API Gateway创建了一个API.现在,我想在每种资源的每种方法上记录每个请求.另外,我需要访问路由的客户端的源IP地址.如何在不编写API函数中编写自定义代码的情况下完成此任务?

I have created an API using AWS API Gateway. Now I want to log each of the request on each method of each resource. Also, I need the source IP address of the client accessing the route. How can I accomplish this without writing custom code in the API functions ?

推荐答案

您的API的默认CloudWatch日志应包括所有标头,包括X-Forwarded-For标头,该标头将包含源IP地址. (请参见 http://docs.aws.amazon .com/apigateway/latest/developerguide/how-to-stage-settings.html )

The default CloudWatch logs for your API should include all headers, including the X-Forwarded-For header which will contain the source IP address. (See http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-stage-settings.html)

如果需要自定义日志记录,则需要在Lambda函数中实现此功能.您可以利用Apex或Serverless之类的东西,编写一些自动化的工具来管理Lambda函数并共享重复的代码.

If you need custom logging you will need to implement this in your Lambda functions. You could take advantage of something like Apex or Serverless and write some automation to manage your Lambda functions and share duplicate code.

这篇关于AWS API Gateway:是否可以在每种API方法中添加源IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆