IIS and Rhodecode 1.5.2 crash

Issue #764 resolved
Thomas Gößler created an issue

When I open the rhodecode web page I get the following error in the log file Rhodecode is running on a Windows Server 2012. I use IIS as a proxy which forwards to the rodecode server. It seams that REMOTE_ADDR includes also the port number which than leads to this error because the port number is not removed. This did not happen with 1.5.1 If I remove the port number in the function "_get_ip_addr in base.py" it works fine.

2013-01-28 11:29:16.815 INFO [rhodecode.lib.base] IP: User: <AuthUser('id:3:Thomas|True')> accessed /
2013-01-28 11:29:16.862 INFO [rhodecode.lib.base] IP: Request to / time: 0.078s
2013-01-28 11:29:22.019 INFO [rhodecode.lib.base] IP: User: <AuthUser('id:3:Thomas|True')> accessed /
2013-01-28 11:29:22.019 INFO [rhodecode.lib.base] IP: Request to / time: 0.031s
Error - <type 'exceptions.ValueError'>: '' does not appear to be an IPv4 or IPv6 address
URL: https://dserver:5000/hg/
File 'C:\\Python27\\lib\\site-packages\\weberror-0.10.3-py2.7.egg\\weberror\\errormiddleware.py', line 162 in __call__
app_iter = self.application(environ, sr_checker)
File 'C:\\Python27\\lib\\site-packages\\beaker-1.6.4-py2.7.egg\\beaker\\middleware.py', line 155 in __call__
return self.wrap_app(environ, session_start_response)
File 'C:\\Python27\\lib\\site-packages\\routes-1.13-py2.7.egg\\routes\\middleware.py', line 131 in __call__
response = self.app(environ, start_response)
File 'C:\\Python27\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\wsgiapp.py', line 107 in __call__
response = self.dispatch(controller, environ, start_response)
File 'C:\\Python27\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\wsgiapp.py', line 312 in dispatch
return controller(environ, start_response)
File 'C:\\Python27\\lib\\site-packages\\rhodecode-1.5.2-py2.7.egg\\rhodecode\\lib\\base.py', line 300 in __call__
return WSGIController.__call__(self, environ, start_response)
File 'C:\\Python27\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 207 in __call__
response = self._inspect_call(self.__before__)
File 'C:\\Python27\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 105 in _inspect_call
result = self._perform_call(func, args)
File 'C:\\Python27\\lib\\site-packages\\pylons-1.0-py2.7.egg\\pylons\\controllers\\core.py', line 57 in _perform_call
return func(**args)
File '<string>', line 2 in __before__
File 'C:\\Python27\\lib\\site-packages\\rhodecode-1.5.2-py2.7.egg\\rhodecode\\lib\\auth.py', line 501 in __wrapper
if not user.ip_allowed:
File 'C:\\Python27\\lib\\site-packages\\rhodecode-1.5.2-py2.7.egg\\rhodecode\\lib\\auth.py', line 408 in ip_allowed
if check_ip_access(source_ip=self.ip_addr, allowed_ips=allowed_ips):
File 'C:\\Python27\\lib\\site-packages\\rhodecode-1.5.2-py2.7.egg\\rhodecode\\lib\\auth.py', line 993 in check_ip_access
if ipaddr.IPAddress(source_ip) in ipaddr.IPNetwork(ip):
File 'C:\\Python27\\lib\\site-packages\\rhodecode-1.5.2-py2.7.egg\\rhodecode\\lib\\ipaddr.py', line 76 in IPAddress
ValueError: '' does not appear to be an IPv4 or IPv6 address
CGI Variables
CONTENT_TYPE: '; charset="utf-8"'
HTTP_ACCEPT: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
HTTP_ACCEPT_CHARSET: 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
HTTP_ACCEPT_ENCODING: 'gzip,deflate,sdch'
HTTP_ACCEPT_LANGUAGE: 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4'
HTTP_COOKIE: 'ViewMode=desktop; rhodecode=5816a5e649cf4a9799dbceae12e9260c; ASP.NET_SessionId=xpeemxkr1e5uvms0dz4rlslz; LogonBrowserType=DefaultWithoutDetection'
HTTP_HOST: 'dserver:5000'
HTTP_USER_AGENT: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11'
HTTP_X_ARR_LOG_ID: '0481c904-587c-453d-b4b8-07c6632471a8'
SERVER_NAME: 'dserver'
WSGI Variables
application: <beaker.middleware.SessionMiddleware object at 0x000000000410CB38>
beaker.get_session: <bound method SessionMiddleware._get_session of <beaker.middleware.SessionMiddleware object at 0x000000000410CB38>>
beaker.session: {'_authentication_token': '8752b087b2849ef14124c734fffc7f2a5a35e696', 'rhodecode_user': {'username': u'Thomas', 'is_authenticated': True, 'user_id': 3}, '_accessed_time': 1359368961.988, '_creation_time': 1357763009.586}
paste.registry: <paste.registry.Registry object at 0x0000000004391588>
paste.throw_errors: True
pylons.controller: <rhodecode.controllers.home.HomeController object at 0x0000000004391AC8>
pylons.environ_config: {'session': 'beaker.session', 'cache': 'beaker.cache'}
pylons.pylons: <pylons.util.PylonsContext object at 0x00000000043919B0>
pylons.routes_dict: {'action': u'index', 'controller': u'home'}
routes.route: <routes.route.Route object at 0x0000000003C2D6D8>
routes.url: <routes.util.URLGenerator object at 0x00000000043918D0>
webob._parsed_query_vars: (GET([]), '')
webob.adhoc_attrs: {'user': <AuthUser('id:3:Thomas|True')>, 'language': 'en-us'}
wsgi process: 'Multithreaded'
wsgi._org_proto: 'http'
wsgi.file_wrapper: <class 'waitress.buffers.ReadOnlyFileBasedBuffer'>
wsgiorg.routing_args: (<routes.util.URLGenerator object at 0x00000000043918D0>, {'action': u'index', 'controller': u'home'})

Comments (13)

  1. Marcin Kuzminski repo owner

    It's an (known) issue with IIS, please fix your setup so it doesn't send the port number together with IP number

  2. Thomas Gößler reporter

    How can I fix this in the IIS. I would be easy to resolve this issue also in base.py

  3. Marcin Kuzminski repo owner

    According to RFC the REMOTE_ADDR header should be a valid IPv4 or IPv6 IP, the added port part is makes it an invalid IP. I'm sorry but IIS is making an error here not RhodeCode, i would rather not mangle the headers to fix this.

    I don't know IIS but from other users told me(with the same issue) there's an easy configuration option to turn it off.

  4. Zachary Greve

    Go the where you turned on the Proxy in IIS, scroll down, and uncheck the box that says 'Append client TCP port number' (at least, I think that is what it says!). I had the same issue and turning that option off fixed it.

  5. Thomas Gößler reporter

    I am using url rewrite for this. I cannot find this option there. Do you have any other idea.


  6. Thomas Gößler reporter

    I updated yesterday andere i habe zu same problem. It does not crash it tells me that my ip address is not allowed

  7. Thomas Gößler reporter

    There is no ip restriction enabled. I get the following message "IP not allowed"

    If I strip the port number as described in my request int the methode _get_ip_addr it is working again.

  8. Marcin Kuzminski repo owner

    It's a misconfiguration, IIS shouldn't send the port number, it's not RhodeCode fault. I'm closing this one now as fixed since the multi-ip problem is fixed

  9. Thomas Gößler reporter

    Do you know someone who could help me resolf this issue in IIS. I am using urlrewrite and I do not find such an option to disable the port number

  10. Log in to comment