Skip to content
Ivo Yankulovski edited this page Sep 17, 2019 · 30 revisions

Localhost development

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

Open terminal in the ProtoSS node.js server folder

  • Configure basic ProtoSS server

  • Execute node index.js and start the server.

  • Configure module Subserver

  • create or copy stats.json in index.js folder

  • check modules\Subserver_stats.json

  • Execute node index.js and start the subserver.

  • Configure example.js

  • check Subserver configuration

  • Execute node example.js and start the example.

  • Configure your own application.js

  • check example.js configuration

  • configure stats.json with 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.js will load and share the same stats.json and 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.

  • Swap of ports in applications

  • starting new application based on server from the same folder will throw an error

  • in each of your applications sharing server folder close and listen the 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);

Apache Configuration

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.

Clone this wiki locally