Wiki
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:nodejs_setup [2014/08/07 11:09]
Michael Armstrong [If Using LSWS Below 4.2.13 or Proxying to an External Server]
litespeed_wiki:nodejs_setup [2014/12/28 16:23] (current)
George Wang [Proxy Node.js Traffic]
Line 28: Line 28:
 ===== Proxy Node.js Traffic ===== ===== Proxy Node.js Traffic =====
  
-Now that Node.js is installed on your server, you will need to tell LSWS to send the proper traffic to your Node.js application. Starting with LSWS 4.2.13, this can be done with a just a rewrite rule (if Node.js is installed on the same server as LSWS). Simply add a rewrite rule that will redirect traffic to the port Node.js is listening on. The following is an example:+Now that Node.js is installed on your server, you will need to tell LSWS to send the proper traffic to your Node.js application. Starting with LSWS 4.2.13, this can be done with a just a rewrite rule (if Node.js is installed on the same server as LSWS). Simply add a rewrite rule that will redirect traffic to the port Node.js is listening on. The following is an example, the domain name for the site is "​example.com",​ Node.js application server is running on port 1337, add the following rewrite rule to .htaccess under document root directory. ​
  
   RewriteEngine On   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-f   RewriteCond %{REQUEST_FILENAME} !-f
-  ​RewriteCond %{REQUEST_FILENAME} !-d +  RewriteRule ^(.*)$ http://example.com:1337/$1 [P,L]
-  ​RewriteRule ^(.*)$ http://127.0.0.1:1337/$1 [P,L]+
  
-The above example redirects all traffic (after checking that it is a directory or file) to port 1337 (where ''​example.js''​ is running, as noted above).+The above example redirects all traffic (after checking that it is a directory or file) to port 1337 (where ''​example.js''​ is running, as noted above). ​Static files are still served by LSWS web server.  
 + 
 +If there is no need to serve static files through LSWS, you can let LSWS proxy all requests to backend application server with rewrite rule 
 + 
 +  RewriteEngine On 
 +  RewriteRule ^(.*)$ http://​example.com:​1337/​$1 [P,L]
  
 ==== If Using LSWS Below 4.2.13 or Proxying to an External Server ==== ==== If Using LSWS Below 4.2.13 or Proxying to an External Server ====
 
litespeed_wiki/nodejs_setup.1407424173.txt.gz · Last modified: 2014/08/07 11:09 by Michael Armstrong