{"action":"created","issue":{"url":"https://api.github.com/repos/nsupdate-info/nsupdate.info/issues/201","labels_url":"https://api.github.com/repos/nsupdate-info/nsupdate.info/issues/201/labels{/name}","comments_url":"https://api.github.com/repos/nsupdate-info/nsupdate.info/issues/201/comments","events_url":"https://api.github.com/repos/nsupdate-info/nsupdate.info/issues/201/events","html_url":"https://github.com/nsupdate-info/nsupdate.info/pull/201","id":68723489,"number":201,"title":"[FIX] get real ip when behind reverse proxy","user":{"login":"hensing","id":1055581,"avatar_url":"https://avatars.githubusercontent.com/u/1055581?v=3","gravatar_id":"","url":"https://api.github.com/users/hensing","html_url":"https://github.com/hensing","followers_url":"https://api.github.com/users/hensing/followers","following_url":"https://api.github.com/users/hensing/following{/other_user}","gists_url":"https://api.github.com/users/hensing/gists{/gist_id}","starred_url":"https://api.github.com/users/hensing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hensing/subscriptions","organizations_url":"https://api.github.com/users/hensing/orgs","repos_url":"https://api.github.com/users/hensing/repos","events_url":"https://api.github.com/users/hensing/events{/privacy}","received_events_url":"https://api.github.com/users/hensing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-15T16:09:13Z","updated_at":"2015-04-15T16:27:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nsupdate-info/nsupdate.info/pulls/201","html_url":"https://github.com/nsupdate-info/nsupdate.info/pull/201","diff_url":"https://github.com/nsupdate-info/nsupdate.info/pull/201.diff","patch_url":"https://github.com/nsupdate-info/nsupdate.info/pull/201.patch"},"body":"When using a (nginx) reverse proxy in front of the (gunicorn) app server, only the local ip is passed to django.\r\nThis fix first tries to obtain the real remote ip via 'HTTP_X_FORWARDED_FOR' and only if it's unset it uses 'REMOTE_ADDR' as remote ip.\r\n\r\n/etc/nginx/sites-available/my_django_project.conf:\r\n    \r\n    ...\r\n        location / {\r\n            proxy_set_header   Host $host;\r\n            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;\r\n            proxy_redirect off;\r\n            proxy_pass http://app_server;\r\n    }"},"comment":{"url":"https://api.github.com/repos/nsupdate-info/nsupdate.info/issues/comments/93476421","html_url":"https://github.com/nsupdate-info/nsupdate.info/pull/201#issuecomment-93476421","issue_url":"https://api.github.com/repos/nsupdate-info/nsupdate.info/issues/201","id":93476421,"user":{"login":"ThomasWaldmann","id":356103,"avatar_url":"https://avatars.githubusercontent.com/u/356103?v=3","gravatar_id":"","url":"https://api.github.com/users/ThomasWaldmann","html_url":"https://github.com/ThomasWaldmann","followers_url":"https://api.github.com/users/ThomasWaldmann/followers","following_url":"https://api.github.com/users/ThomasWaldmann/following{/other_user}","gists_url":"https://api.github.com/users/ThomasWaldmann/gists{/gist_id}","starred_url":"https://api.github.com/users/ThomasWaldmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThomasWaldmann/subscriptions","organizations_url":"https://api.github.com/users/ThomasWaldmann/orgs","repos_url":"https://api.github.com/users/ThomasWaldmann/repos","events_url":"https://api.github.com/users/ThomasWaldmann/events{/privacy}","received_events_url":"https://api.github.com/users/ThomasWaldmann/received_events","type":"User","site_admin":false},"created_at":"2015-04-15T16:27:47Z","updated_at":"2015-04-15T16:27:47Z","body":"i also use a nginx reverse proxy that sits in front of another nginx. in the inner one i use the \"realip\" extension to get the right remote address. does gunicorn have something similar? also the scheme might be worth a look (http vs. https)."}}