{"id":14466,"date":"2014-06-30T23:49:44","date_gmt":"2014-06-30T18:19:44","guid":{"rendered":"https:\/\/2thenew.online\/blog\/?p=14466"},"modified":"2014-06-30T23:49:44","modified_gmt":"2014-06-30T18:19:44","slug":"getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer","status":"publish","type":"post","link":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/","title":{"rendered":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer"},"content":{"rendered":"<p><span>When placing nginx \u00a0web servers behind a Elastic load balancer\u00a0\u00a0, the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP<\/span><\/p>\n<p><span style=\"color: #141412\">Here\u2019s how you can fix it and capture the real IP.<\/span><\/p>\n<p><span>Prerequisite<\/span><\/p>\n<p><span>Make sure you have\u00a0<\/span><strong>http_realip_module <\/strong>with\u00a0nginx<strong>\u00a0<\/strong><span>. You can check it this way:<\/span><\/p>\n<pre><span>nginx -V<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><span>Open \/etc\/nginx\/nginx.conf file and add following parameters inside http block.<\/span><\/p>\n<pre>vi\u00a0\/etc\/nginx\/nginx.conf\r\n\r\nhttp { ..\r\nreal_ip_header X-Forwarded-For;\r\nset_real_ip_from 0.0.0.0\/0;\r\n..}<\/pre>\n<p>&nbsp;<\/p>\n<p><span>After this reload the nginx and check the access logs.<\/span><\/p>\n<p><span>Note : If the traffic \u00a0only coming through elastic load balancer , then set\u00a0\u00a0IP address assigned to elastic load balancer.<\/span><\/p>\n<p><span>Suppose IP address for elastic load balance\u00a0 is 1.1.1.1, then it should look like<\/span><\/p>\n<pre>set_real_ip_from 1.1.1.1;<\/pre>\n<address>\u00a0<\/address>\n<address>Thanks<\/address>\n<address>Prashant Sharma<\/address>\n","protected":false},"excerpt":{"rendered":"<p>When placing nginx \u00a0web servers behind a Elastic load balancer\u00a0\u00a0, the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have\u00a0http_realip_module with\u00a0nginx\u00a0. You can check [&hellip;]<\/p>\n","protected":false},"author":120,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":28,"footnotes":""},"categories":[1174],"tags":[],"class_list":["post-14466","post","type-post","status-publish","format-standard","hentry","category-aws-2"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Prashant Sharma\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#article\",\"name\":\"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog\",\"headline\":\"Getting real IP while using nginx working behind Amazon Elastic Load Balancer\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/prashant-sharma\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2014-06-30T23:49:44+05:30\",\"dateModified\":\"2014-06-30T23:49:44+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#webpage\"},\"articleSection\":\"AWS\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/#listItem\",\"name\":\"AWS\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/#listItem\",\"position\":2,\"name\":\"AWS\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#listItem\",\"name\":\"Getting real IP while using nginx working behind Amazon Elastic Load Balancer\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#listItem\",\"position\":3,\"name\":\"Getting real IP while using nginx working behind Amazon Elastic Load Balancer\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/#listItem\",\"name\":\"AWS\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/prashant-sharma\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/prashant-sharma\\\/\",\"name\":\"Prashant Sharma\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b323e7299ad62c86e5be8760ed5746d614dc352e6c25661acd529affebcab0b9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Prashant Sharma\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/\",\"name\":\"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog\",\"description\":\"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/prashant-sharma\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/prashant-sharma\\\/#author\"},\"datePublished\":\"2014-06-30T23:49:44+05:30\",\"dateModified\":\"2014-06-30T23:49:44+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog","description":"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check","canonical_url":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#article","name":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog","headline":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer","author":{"@id":"https:\/\/2thenew.online\/blog\/author\/prashant-sharma\/#author"},"publisher":{"@id":"https:\/\/2thenew.online\/blog\/#organization"},"datePublished":"2014-06-30T23:49:44+05:30","dateModified":"2014-06-30T23:49:44+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#webpage"},"isPartOf":{"@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#webpage"},"articleSection":"AWS"},{"@type":"BreadcrumbList","@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog#listItem","position":1,"name":"Home","item":"https:\/\/2thenew.online\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/aws-2\/#listItem","name":"AWS"}},{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/aws-2\/#listItem","position":2,"name":"AWS","item":"https:\/\/2thenew.online\/blog\/category\/aws-2\/","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#listItem","name":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer"},"previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#listItem","position":3,"name":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer","previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/aws-2\/#listItem","name":"AWS"}}]},{"@type":"Organization","@id":"https:\/\/2thenew.online\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/2thenew.online\/blog\/"},{"@type":"Person","@id":"https:\/\/2thenew.online\/blog\/author\/prashant-sharma\/#author","url":"https:\/\/2thenew.online\/blog\/author\/prashant-sharma\/","name":"Prashant Sharma","image":{"@type":"ImageObject","@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/b323e7299ad62c86e5be8760ed5746d614dc352e6c25661acd529affebcab0b9?s=96&d=mm&r=g","width":96,"height":96,"caption":"Prashant Sharma"}},{"@type":"WebPage","@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#webpage","url":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/","name":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog","description":"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/2thenew.online\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/#breadcrumblist"},"author":{"@id":"https:\/\/2thenew.online\/blog\/author\/prashant-sharma\/#author"},"creator":{"@id":"https:\/\/2thenew.online\/blog\/author\/prashant-sharma\/#author"},"datePublished":"2014-06-30T23:49:44+05:30","dateModified":"2014-06-30T23:49:44+05:30"},{"@type":"WebSite","@id":"https:\/\/2thenew.online\/blog\/#website","url":"https:\/\/2thenew.online\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/2thenew.online\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog","og:description":"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check","og:url":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/","og:image":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer | TO THE NEW Blog","twitter:description":"When placing nginx web servers behind a Elastic load balancer , the client IP address from the browser is replaced with the IP address of the load-balancer. This makes difficult to analysis the location of IP Here\u2019s how you can fix it and capture the real IP. Prerequisite Make sure you have http_realip_module with nginx . You can check","twitter:image":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"14466","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 14:36:25","updated":"2024-02-29 09:16:52","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.online\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.online\/blog\/category\/aws-2\/\" title=\"AWS\">AWS<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tGetting real IP while using nginx working behind Amazon Elastic Load Balancer\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/2thenew.online\/blog"},{"label":"AWS","link":"https:\/\/2thenew.online\/blog\/category\/aws-2\/"},{"label":"Getting real IP while using nginx working behind Amazon Elastic Load Balancer","link":"https:\/\/2thenew.online\/blog\/getting-real-ip-while-using-nginx-working-behind-amazon-elastic-load-balancer\/"}],"_links":{"self":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts\/14466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/users\/120"}],"replies":[{"embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/comments?post=14466"}],"version-history":[{"count":0,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts\/14466\/revisions"}],"wp:attachment":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/media?parent=14466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/categories?post=14466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/tags?post=14466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}