-
Notifications
You must be signed in to change notification settings - Fork 1
HowTo
Configure hosts file if you have to /etc/hosts and add your subdomain:
127.0.0.1 localhost
127.0.0.1 my.nodewebsite.com.localhost
-
Execute node index.js and start the server.
-
create or copy
stats.jsoninindex.jsfolder -
check
modules\Subserver_stats.json -
Execute node index.js and start the subserver.
-
check
Subserverconfiguration -
Execute node example.js and start the example.
-
check
example.jsconfiguration -
configure
stats.jsonwith the right server module, you might use your own implementation -
server starts automatically, you might choose to stop it and execute different logic
-
several applications requiring the same
index.jswill load and share the samestats.jsonand therefor base server module -
one application may create several different instances on different ports depending on implementation, sharing static properties with all other servers and applications pointing to the same folder
-
Execute node application.js and start your app.
-
starting new application based on server from the same folder will throw an error
-
in each of your applications sharing server folder
closeandlistenthe http server using your own port, you might choose to load it from a separate.json -
code example:
var myport = 5000;
var protossche = require('./index.js');
protossche.serverche.htserv.close().listen(myport);
Load or enable in your httpd file the proxy modules:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Add to your vhost configuration of ServerName my.nodewebsite.com.localhost the proxy line:
ProxyPass /node http://my.nodewebsite.com.localhost:8888/node
/node is your base url, you might omit it in the node.js url
http://my.nodewebsite.com.localhost is your node.js host
8888 is your node.js listen port
Create folder node in the root of your domain and create .htaccess with the following code:
RewriteEngine On
RewriteBase /
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE can be placed in several places including root .htaccess
including your main httpd file, if you have access to it
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
Requires deflate module enabled.
LoadModule deflate_module modules/mod_deflate.so
Sample vhost for localhost:
<VirtualHost *:80>
ServerName my.nodewebsite.com.localhost
ServerAlias my.nodewebsite.com.localhost
DocumentRoot "Drive:\path\to\website"
ProxyPass /node http://my.nodewebsite.com.localhost:8888/node
<Directory "Drive:\path\to\website">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
The Apache configuration can be modified to work with NGINX server.
Caching of assets depends on all the other configurations.
Node.js works with PHP simultaneously. Logic is separated by folder.