Beginner, simple implementation, for optimization.
1. Assume that the Nodejs server is listening on port 3000
2. Apache Reverse proxy settings
A. Opening the proxy module in the httpd.conf configuration file
LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.so |
B. Introduction of the VirtualHost configuration file httpd-vhosts.conf
Include conf/extra/httpd-vhosts.conf |
C. Configure the listening port in httpd.conf, this is the case of Port 8010, you can set the other ports yourself
D. Declaring a port that matches httpd.conf in httpd-vhosts.conf
E. Reverse proxy settings in httpd-vhosts.conf
<VirtualHost *:8010> ServerName www.socketio.chat.com ServerAlias socketio.chat.com ErrorLog "logs/socketio.com-error.log" CustomLog "logs/socketio.com-access.log"common ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> #反向代理设置 ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/</VirtualHost> |
3. The configuration is complete, access to the localhost:8010 can be accessed to the Nodejs service through 3000 port services
4. Unresolved issues
A. The client first access localhost:8010 will return 502 information, waiting for about 3s to connect the Nodejs service, do not know whether it is socketio or Apache or Nodejs
B. Nodejs server will continue to set/clear heartbeat, even if no data need to push the day after tomorrow, the client will still receive polling data regularly
C. Client connection is not stable, drop line frequently
Nodejs Study Notes