Nginx not passing the AWS API gateway ID to EC2 in request header User-Agent

  amazon-ec2, nginx, nginx-config, nginx-location, php

I have setup and nginx base ec2 instance. This instance received request from AWS API Gateway. When I receive request in code then request has not received desired pattern headers User-Agent

Required User-Agent Pattenr

aws-sdk-android/2.22.6 Linux/3.18.14-14263629-QB33208447 Dalvik/2.1.0/0 en_US appVersion/128 apiVersion/4.5 device-id/([email protected]) df1, AmazonAPIGateway_n6t1xjtsb2

But when I receive request User-Agent is

aws-sdk-android/2.22.6 Linux/3.18.14-14263629-QB33208447 Dalvik/2.1.0/0 en_US appVersion/128 apiVersion/4.5 device-id/([email protected]) df1

I want to append the AWS API Gateway Id with request User-Agent.
Below is nginx server configuration.

#Modifed Elastic Beanstalk Nginx Configuration File
user                    nginx;
error_log               /var/log/nginx/error.log warn;
pid                     /var/run/nginx.pid;
worker_processes        auto;
worker_rlimit_nofile    66966;
events {
    worker_connections  1024;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                      '$status $body_bytes_sent "$http_referer" ';
                     
    include       conf.d/*.conf;
    map $http_upgrade $connection_upgrade {
        default     "upgrade";
    }
    server {
        listen        80 default_server;
        access_log    /var/log/nginx/access.log main;
        client_header_timeout 60;
        client_body_timeout   60;
        keepalive_timeout     60;
        gzip                  off;
        gzip_comp_level       4;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
        # Include the Elastic Beanstalk generated locations
        include conf.d/elasticbeanstalk/*.conf;
    }
}

Source: Ask PHP

LEAVE A COMMENT