0
Under review

Apache 2.4.x revese proxy error 500 and 502

Xarkam 10 years ago updated 10 years ago 12
Hello, I configured a wirtual host for ajenti with proxypass reverse.
But I have one error 500 and 502 error's.

This is my apache configuration

<VirtualHost *:443>
        ServerName ajenti.XXXXX.org

        SSLEngine on
        SSLProxyEngine On
        SSLCertificateFile    /etc/ssl/XXXXX_webserver_ssl.crt
        SSLCertificateKeyFile /etc/ssl/XXXXX_webserver_ssl.key
        #SSLVerifyClient none

        <IfModule mod_disk_cache.c>
                 # "/s" is where Confluence serves "static" stuff. Instruct Apache to cache it:
                 CacheEnable disk /s
                 CacheIgnoreHeaders Set-Cookie
                 CacheRoot "/var/cache/mod_proxy"
        </IfModule>

        # Ajenti Proxy Configuration:
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        RequestHeader set Origin https://192.168.0.200:8010

        ProxyRequests           Off
        ProxyPreserveHost       On
        ProxyPass               /       https://192.168.0.200:8010/
        ProxyPassReverse        /       https://192.168.0.200:8010/
        ProxyPass /ajenti:socket/1/websocket/ ws://192.168.0.200:8010/ajenti:socket/1/websocket/

        ErrorLog "/var/log/apache2/ajenti.log"
        CustomLog "/var/log/apache2/ajenti-access.log" common

</VirtualHost>
Firefox Networking:
Image 75Image 76

what is misconfigured?



Under review
Could you please check /var/log/ajenti/ajenti.log?
Many error in log:
@intranet:/home/xarkam# cat /var/log/ajenti/ajenti.log
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 508, in handle_one_response
    self.run_application()
  File "/usr/lib/python2.7/dist-packages/geventwebsocket/handler.py", line 88, in run_application
    return super(WebSocketHandler, self).run_application()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 494, in run_application
    self.result = self.application(self.environ, self.start_response)
  File "/usr/lib/pymodules/python2.7/ajenti/http.py", line 30, in dispatch
    output = middleware.handle(context)
  File "/usr/lib/pymodules/python2.7/ajenti/profiler.py", line 45, in wrapper
    r = fx(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/ajenti/routing.py", line 47, in handle
    return context.fallthrough(self.io)
  File "/usr/lib/pymodules/python2.7/ajenti/http.py", line 102, in fallthrough
    return handler.handle(self)
  File "/usr/lib/pymodules/python2.7/ajenti/routing.py", line 18, in handle
    return str(socketio.socketio_manage(context.env, self.namespaces, context))
  File "/usr/lib/pymodules/python2.7/socketio/__init__.py", line 60, in socketio_manage
    socket = environ['socketio']
KeyError: 'socketio'
{'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
 'HTTP_ACCEPT_LANGUAGE': 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3',
 'HTTP_CACHE_CONTROL': 'no-cache',
 'HTTP_CONNECTION': 'Keep-Alive',
 'HTTP_COOKIE': 'phpbb3_lv41q_k=; phpbb3_lv41q_u=2; phpbb3_lv41q_sid=5a6993bd981ab332e9f21d06faf3f910; style_cookie=null; mp_b5e6ddf58b2d02245a7a19005d1cec48_mixpanel=%7B%22distinct_id%22%3A%20%221455f751dc834-097b2e530aec7f-4a594337-1fa400-1455f751dc99f%22%7D; adblock=0; JSESSIONID=3C4D178C76F28739AA804397FE909BCE; session=87bf6356351a631d982894fe27c1363e83e9c496',
 'HTTP_DNT': '1',
 'HTTP_HOST': 'ajenti.XXXXX.org',
 'HTTP_ORIGIN': 'https://192.168.0.200:8010',
 'HTTP_PRAGMA': 'no-cache',
 'HTTP_SEC_WEBSOCKET_KEY': 'WqqGCQB71sVkoRWfwrznDA==',
 'HTTP_SEC_WEBSOCKET_VERSION': '13',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (Wi2014-09-24 15:01:09,594 INFO     handler.log_request(): 192.168.0.200 - - [2014-09-24 15:01:09] "GET /ajenti:socket/1/websocket/677996853883 HTTP/1.1" 500 161 0.004750
RVER': 'ajenti.XXXXXX.org',
 'PATH_INFO': '/ajenti:socket/1/websocket/677996853883',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '192.168.0.200',
 'REMOTE_PORT': '55272',
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'localhost.localdomain',
 'SERVER_PORT': '8010',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'gevent/1.0 Python/2.7',
 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7ffe687d61e0>,
 'wsgi.input': <gevent.pywsgi.Input object at 0x7ffe5bfe6b10>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'https',
 'wsgi.version': (1, 0)} failed with KeyError

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 103, in wrap_socket_and_handle
    return self.handle(ssl_socket, address)
  File "/usr/lib/pymodules/python2.7/socketio/server.py", line 70, in handle
    handler.handle()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 184, in handle
    result = self.handle_one_request()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 321, in handle_one_request
    self.handle_one_response()
  File "/usr/lib/pymodules/python2.7/socketio/handler.py", line 123, in handle_one_response
    jobs = self.transport.connect(socket, request_method)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 215, in connect
    websocket = self.handler.environ['wsgi.websocket']
KeyError: 'wsgi.websocket'
<Greenlet at 0x7ffe5bfdc0f0: <bound method SocketIOServer.wrap_socket_and_handle of <SocketIOServer at 0x7ffe5ca5bad0 fileno=9 address=0.0.0.0:8010>>(<socket at 0x7ffe5bfe6850 fileno=-1>, ('192.168.0.200', 55272))> failed with KeyError

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 103, in wrap_socket_and_handle
    return self.handle(ssl_socket, address)
  File "/usr/lib/pymodules/python2.7/socketio/server.py", line 70, in handle
    handler.handle()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 184, in handle
    result = self.handle_one_request()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 321, in handle_one_request
    self.handle_one_response()
  File "/usr/lib/pymodules/python2.7/socketio/handler.py", line 123, in handle_one_response
    jobs = self.transport.connect(socket, request_method)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 138, in connect
    self.write("1::")  # 'connect' packet
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 22, in write
    if 'Content-Length' not in self.handler.response_headers_list:
AttributeError: 'SocketIOHandler' object has no attribute 'response_headers_list'
<Greenlet at 0x7ffe5bfdc0f0: <bound method SocketIOServer.wrap_socket_and_handle of <SocketIOServer at 0x7ffe5ca5bad0 fileno=9 address=0.0.0.0:8010>>(<socket at 0x7ffe5bfe6890 fileno=-1>, ('192.168.0.200', 55280))> failed with AttributeError

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 103, in wrap_socket_and_handle
    return self.handle(ssl_socket, address)
  File "/usr/lib/pymodules/python2.7/socketio/server.py", line 70, in handle
    handler.handle()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 184, in handle
    result = self.handle_one_request()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 321, in handle_one_request
    self.handle_one_response()
  File "/usr/lib/pymodules/python2.7/socketio/handler.py", line 123, in handle_one_response
    jobs = self.transport.connect(socket, request_method)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 142, in connect
    return getattr(self, request_method.lower())(socket)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 54, in get
    self.write(payload)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 162, in write
    super(JSONPolling, self).write("io.j[0]('%s');" % data)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 22, in write
    if 'Content-Length' not in self.handler.response_headers_list:
AttributeError: 'SocketIOHandler' object has no attribute 'response_headers_list'
<Greenlet at 0x7ffe5bfdc0f0: <bound method SocketIOServer.wrap_socket_and_handle of <SocketIOServer at 0x7ffe5ca5bad0 fileno=9 address=0.0.0.0:8010>>(<socket at 0x7ffe5bfe6fd0 fileno=-1>, ('192.168.0.200', 55282))> failed with AttributeError

Does it work if you comment out ws:// ProxyPass?
No, I added the ws ProxyPass and RequestHeader because, Ajenti not running in https. If I remove the ssl of ajenti configuration, and make it accessible by port 80 in apache, then ajenti run.

I already tested by commented the ws ProxyPass line.

I using the auto generated certificate by Ajenti.
-1
Sorry, I didn't notice that you were using SSL. In this case, you need to use wss:// websocket URL. 
I'm not sure if this will resolve your problem fully - I'll set up your configuration at my side for testing later today.
I had success with this config (note the proxypass order):
<VirtualHost *:82>

SSLProxyEngine On
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerExpire Off

RequestHeader set Origin https://localhost:8000

ProxyPass /ajenti https://localhost:8000/
ProxyPass /ajenti:socket/1/websocket/ wss://localhost:8000/ajenti:socket/1/websocket/
ProxyPassMatch ^/(ajenti:.*)$ https://localhost:8000/$1
ProxyPassReverse /ajenti /

</VirtualHost>

Okay. For you information, no change with using wss://
Hello, I modified my configuration and it's also same comportment
Here is ajenti.log
intranet:/var/log/ajenti# cat ajenti.log
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 102, in wrap_socket_and_handle
    ssl_socket = self.wrap_socket(client_socket, **self.ssl_args)
  File "/usr/lib/python2.7/dist-packages/gevent/ssl.py", line 383, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/dist-packages/gevent/ssl.py", line 94, in __init__
    self.do_handshake()
  File "/usr/lib/python2.7/dist-packages/gevent/ssl.py", line 305, in do_handshake
    return self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:510: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request
<Greenlet at 0x7f80cafcf370: <bound method SocketIOServer.wrap_socket_and_handle of <SocketIOServer at 0x7f80cba4fd10 fileno=9 address=0.0.0.0:8010>>(<socket at 0x7f80caf6e450 fileno=19 sock=127.0.0.1, ('127.0.0.1', 51109))> failed with SSLError

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 103, in wrap_socket_and_handle
    return self.handle(ssl_socket, address)
  File "/usr/lib/pymodules/python2.7/socketio/server.py", line 70, in handle
    handler.handle()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 184, in handle
    result = self.handle_one_request()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 321, in handle_one_request
    self.handle_one_response()
  File "/usr/lib/pymodules/python2.7/socketio/handler.py", line 123, in handle_one_response
    jobs = self.transport.connect(socket, request_method)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 138, in connect
    self.write("1::")  # 'connect' packet
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 22, in write
    if 'Content-Length' not in self.handler.response_headers_list:
AttributeError: 'SocketIOHandler' object has no attribute 'response_headers_list'
<Greenlet at 0x7f80cafcf370: <bound method SocketIOServer.wrap_socket_and_handle of <SocketIOServer at 0x7f80cba4fd10 fileno=9 address=0.0.0.0:8010>>(<socket at 0x7f80caf6e550 fileno=-1>, ('127.0.0.1', 51112))> failed with AttributeError

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/lib/python2.7/dist-packages/gevent/server.py", line 103, in wrap_socket_and_handle
    return self.handle(ssl_socket, address)
  File "/usr/lib/pymodules/python2.7/socketio/server.py", line 70, in handle
    handler.handle()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 184, in handle
    result = self.handle_one_request()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 321, in handle_one_request
    self.handle_one_response()
  File "/usr/lib/pymodules/python2.7/socketio/handler.py", line 123, in handle_one_response
    jobs = self.transport.connect(socket, request_method)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 142, in connect
    return getattr(self, request_method.lower())(socket)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 54, in get
    self.write(payload)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 162, in write
    super(JSONPolling, self).write("io.j[0]('%s');" % data)
  File "/usr/lib/pymodules/python2.7/socketio/transports.py", line 22, in write
    if 'Content-Length' not in self.handler.response_headers_list:
AttributeError: 'SocketIOHandler' object has no attribute 'response_headers_list'
<Greenlet at 0x7f80cafcf370: <bound method SocketIOServer.wrap_socket_and_handle of <SocketIOServer at 0x7f80cba4fd10 fileno=9 address=0.0.0.0:8010>>(<socket at 0x7f80caf6e450 fileno=-1>, ('127.0.0.1', 51132))> failed with AttributeError
Can you please post your updated configuration?
<VirtualHost *:443>
        ServerName ajenti.XXXXX.org

        SSLEngine on
        SSLProxyEngine On
        SSLCertificateFile    /etc/ssl/webserver_ssl.crt
        SSLCertificateKeyFile /etc/ssl/webserver_ssl.key
        SSLProxyCheckPeerCN Off
        SSLProxyCheckPeerExpire Off

        <IfModule mod_disk_cache.c>
                 # "/s" is where Confluence serves "static" stuff. Instruct Apache to cache it:
                 CacheEnable disk /s
                 CacheIgnoreHeaders Set-Cookie
                 CacheRoot "/var/cache/mod_proxy"
        </IfModule>

        # Ajenti Proxy Configuration:
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        RequestHeader set Origin https://localhost:8010

        ProxyRequests           Off
        ProxyPreserveHost       On
        ProxyPass /ajenti https://localhost:8010/
        ProxyPass /ajenti:socket/1/websocket/ wss://localhost:8010/ajenti:socket/1/websocket/
        ProxyPassMatch ^/(ajenti:.*)$ https://localhost:8010/$1
        ProxyPassReverse /ajenti /

        ErrorLog "/var/log/apache2/ajenti.log"
        CustomLog "/var/log/apache2/ajenti-access.log" common

</VirtualHost>
Please remove ProxyRequests and ProxyPreserveHost, it doesn't work for me with those either.
Now, I have the ajenti page with nothing in.
Juste header bar with home picture and logout.