Apache configures the WebSocket protocol

This article uses http proxy to implement apache to support WebSocket requests (ajp protocol used by JK cannot support websocket)

For the http proxy method, please refer to: http://blog.csdn.NET/conquer0715/article/details/42043411

 

To access the websocket service on the back-end tomcat through apache, you need to use two library files, mod_proxy.so and mod_proxy_wstunnel.so (which already exist in the apache2.4 installation directory, and can be used by releasing the comments in the httpd.conf file). In the application, if you need to access some pages (such as index pages) through the http protocol, you need to add mod_proxy_http.so, as follows:

[java] view plaincopy    
 
  1. LoadModule proxy_module modules/mod_proxy.so  
  2.   
  3. LoadModule proxy_http_module modules/mod_proxy_http.so  
  4.   
  5. LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so  
  6. Add at the end:  
  7. ProxyPass /web/websocket/ ws://l:8080/web/websocket/  
  8. ProxyPass / http://127.0.0.1:8080/  

My apache port is 7000, so when I visit http://127.0.0.1:7000/web/, the index.html home page appears (this visit is not a websocket, so I need to open mod_proxy_http.so, if you don't need it, you can close the loading mod_proxy_http.so )

The websocket services configured in my application are all under web/websocket/, so the mapping is configured. For all other mappings such as "/", it needs to be configured after the web/websocket/ mapping, otherwise the mapping of web/websocket/ will be regarded as HTTP protocol processing.

 

 

Note: WebSocket load balancing has no affinity/non-affinity concept! ! !   

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326212085&siteId=291194637