Skip to content

unable to hide behind apache proxypass, websocket has error #442

Closed

Description

@peterremote1980

unable to hide behind apache proxypass, websocket has error:

c01964.bundle.js:53 WebSocket connection to 'wss://code.quantr.hk/' failed: Error during WebSocket handshake: Unexpected response code: 200

<VirtualHost *:80>
        ServerAdmin peter@quantr.hk
        ServerName code.quantr.hk
        ServerAlias code.quantr.com
        ProxyPass / http://192.168.10.124:8443/
        ProxyPassReverse / http://192.168.10.124:8443/
</VirtualHost>



<VirtualHost *:443>
            ProxyRequests Off

    SSLEngine On
    SSLProxyEngine On
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off

        SSLCertificateFile /etc/letsencrypt/live/mail.findjob.la/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mail.findjob.la/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf

        ServerAdmin peter@quantr.hk
        ServerName code.quantr.hk
        ServerAlias code.quantr.com
        ProxyPass / https://192.168.10.124:8443/
        ProxyPassReverse / https://192.168.10.124:8443/
</VirtualHost>
/root/Downloads/code-server1.604-vsc1.32.0-linux-x64/code-server  -P password --cert /etc/letsencrypt/live/mail.findjob.la/fullchain.pem --cert-key /etc/letsencrypt/live/mail.findjob.la/privkey.pem ~/workspace/

Activity

  1. edwinbrowwn commented on Apr 5, 2019

    @edwinbrowwn

    What modules are are you using with apache?
    Don't forget to open port 8443.

  2. peterremote1980 commented on Apr 5, 2019

    @peterremote1980
    Author

    I am using ProxyPass module, i confirm 8443 is opened.

  3. edwinbrowwn commented on Apr 5, 2019

    @edwinbrowwn

    ProxyPass is just an argument in the config. Make sure you have the respective apache modules installed to support headers and such.
    Here is the command to install the mod_prox module.
    apt install -y build-essential
    apt install -y libapache2-mod-proxy-html libxml2-dev
    a2enmod
    proxy proxy_ajp proxy_http rewrite deflate headers proxy_connect proxy_html
    You will then see a list of modules you can install. Then restart after you have what you need.

  4. abl commented on Apr 7, 2019

    @abl

    https://github.com/codercom/code-server/blob/master/doc/self-hosted/index.md#apache-reverse-proxy

    Take a look at that; you're missing a few config directives that are causing your websockets to be treated like normal HTTP requests. (Unexpected response code: 200 means that your websocket request is getting a normal web page back.)

  5. sr229 commented on Apr 9, 2019

    @sr229
    Contributor

    From first glance your configuration does not support HTTP upgrades, which the websocket needs.

  6. ColdSphinX commented on Apr 15, 2019

    @ColdSphinX

    You might want to use rewrite to proxy depending on http upgrade.

    RewriteEngine On
    RewriteCond %{HTTP:Upgrade} =websocket
    RewriteRule /(.*) ws://192.168.10.124:8443/$1 [P,QSA,L]
    RewriteCond %{HTTP:Upgrade} !=websocket
    RewriteRule /(.*) http://192.168.10.124:8443/$1 [P,QSA,L]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwaiting-for-infoWaiting for more information from submitter

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions