mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Merged 1.9 update for behind-proxy support
This commit is contained in:
commit
b5baea184f
@ -282,6 +282,9 @@ class GlobalConfig(object):
|
|||||||
# Allow clients to notify their own ip (if set), or use always the request extracted IP
|
# Allow clients to notify their own ip (if set), or use always the request extracted IP
|
||||||
HONOR_CLIENT_IP_NOTIFY = Config.section(SECURITY_SECTION).value('honorClientNotifyIP', '0', type=Config.BOOLEAN_FIELD)
|
HONOR_CLIENT_IP_NOTIFY = Config.section(SECURITY_SECTION).value('honorClientNotifyIP', '0', type=Config.BOOLEAN_FIELD)
|
||||||
|
|
||||||
|
# If there is a proxy in front of us
|
||||||
|
BEHIND_PROXY = Config.section(SECURITY_SECTION).value('Behind a proxy', '0', type=Config.BOOLEAN_FIELD)
|
||||||
|
|
||||||
# Clusters related vars
|
# Clusters related vars
|
||||||
|
|
||||||
# Maximum desired CPU Load. If cpu is over this value, a migration of a service is "desirable"
|
# Maximum desired CPU Load. If cpu is over this value, a migration of a service is "desirable"
|
||||||
|
@ -33,12 +33,13 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from uds.core.util import OsDetector
|
from uds.core.util import OsDetector
|
||||||
from uds.core.auths.auth import ROOT_ID, USER_KEY, getRootUser
|
from uds.core.auths.auth import ROOT_ID, USER_KEY, getRootUser
|
||||||
|
from uds.core.util.Config import GlobalConfig
|
||||||
from uds.models import User
|
from uds.models import User
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__updated__ = '2016-04-06'
|
__updated__ = '2016-04-22'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ class GlobalRequestMiddleware(object):
|
|||||||
|
|
||||||
Returns the obtained IP, that is always be a valid ip address.
|
Returns the obtained IP, that is always be a valid ip address.
|
||||||
'''
|
'''
|
||||||
|
behind_proxy = GlobalConfig.BEHIND_PROXY.getBool(False)
|
||||||
try:
|
try:
|
||||||
request.ip = request.META['REMOTE_ADDR']
|
request.ip = request.META['REMOTE_ADDR']
|
||||||
except:
|
except:
|
||||||
@ -98,6 +100,11 @@ class GlobalRequestMiddleware(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
request.ip_proxy = request.META['HTTP_X_FORWARDED_FOR'].split(",")[0]
|
request.ip_proxy = request.META['HTTP_X_FORWARDED_FOR'].split(",")[0]
|
||||||
|
|
||||||
|
if behind_proxy is True:
|
||||||
|
request.ip = request.ip_proxy
|
||||||
|
request.ip_proxy = request.META['HTTP_X_FORWARDED_FOR'].split(",")[1] # Try to get next proxy
|
||||||
|
|
||||||
request.is_proxy = True
|
request.is_proxy = True
|
||||||
except:
|
except:
|
||||||
request.ip_proxy = request.ip
|
request.ip_proxy = request.ip
|
||||||
|
Loading…
Reference in New Issue
Block a user