-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
NetBox version
v3.0.10
Python version
3.8
Steps to Reproduce
Background: #7876
python snippet:
remote_ip_address = self.request.META.get('HTTP_X_FORWARDED_FOR') or self.request.META.get('REMOTE_ADDR')
self.log_info(f"Running as user {remote_username} (IP: {remote_ip_address})...")
self.log_info(repr(self.request.META))
my nginx snippet:
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
}
Expected Behavior
{'CONTENT_LENGTH': '503', 'CONTENT_TYPE': 'multipart/form-data; boundary=----WebKitFormBoundaryw66ayIoNmlX9BFq7', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, br', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.9', 'HTTP_HOST': '127.0.0.1:8001', 'HTTP_REFERER': 'https://netbox-lab.nwk.jwm2.net/extras/scripts/netbox.AddDevice/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'POST', 'SERVER_NAME': '127.0.0.1', 'SERVER_PORT': '8001', 'HTTP_X_FORWARDED_FOR': 'x.x.x.48'}
HTTP_X_FORWARDED_FOR should be present as nginx set it.
Observed Behavior
The above would give me the below output:
{'CONTENT_LENGTH': '503', 'CONTENT_TYPE': 'multipart/form-data; boundary=----WebKitFormBoundaryPrHAvPRqa4n0y5Bn', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, br', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.9', 'HTTP_HOST': '127.0.0.1:8001', 'HTTP_REFERER': 'https://netbox.domain.com/extras/scripts/netbox.AddDevice/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'POST', 'SERVER_NAME': '127.0.0.1', 'SERVER_PORT': '8001'}
Metadata
Metadata
Assignees
Labels
status: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application