Michael
Michael

Reputation: 33317

Apache2 Proxy WebSocket Connections?

System: ubuntu 12.04LTS

I use Apache as Proxy server for my Tomcat7 webserver.

For Apache as Proxy I activated the modules:

sudo a2enmod proxy
sudo a2enmod proxy_http

Then I edit the /etc/apache2/sites-available/default as:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

       ProxyRequests Off
       ProxyPass / http://localhost:8080/
       ProxyPassReverse / http://localhost:8080/

       <Location "/">
               Order allow,deny
               Allow from all
       </Location>


    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

I am using Websockets so I need to enable them. How can I do that in the Apache Proxy server?

Chrome shows me this error:

WebSocket connection to 'ws://www.myapp.com/socket/848df2e62fcf93e1b3?X-Atmosphere-tracking-i…Date=0&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true' 
failed: Unexpected response code: 200

Upvotes: 1

Views: 2805

Answers (1)

haoudoin
haoudoin

Reputation: 151

You are seeing that error likely because your version of Apache does not support HTTP 1.1. To configure your Apache to support websockets, try following this:

https://serverfault.com/questions/290121/configuring-apache2-to-proxy-websocket

EDIT: Removing remainder of post as it is off subject

Upvotes: 1

Related Questions