All Projects → lo-tp → Meteorn

lo-tp / Meteorn

Licence: mit
MeteorN - A Simple Tool to Run Meteor App with an Nginx Reverse Proxy

Labels

Projects that are alternatives of or similar to Meteorn

Nginx Headers More Rpm
Nginx with headers-more-module rpm
Stars: ✭ 6 (-76%)
Mutual labels:  nginx
Nginx Nonewlines
This is an nginx module to strip the served HTML of all newlines (\n and \r characters)
Stars: ✭ 17 (-32%)
Mutual labels:  nginx
React Express Fullstack
Full stack (mostly unopinionated) starter pack with React+Redux and Expressjs
Stars: ✭ 23 (-8%)
Mutual labels:  nginx
Keyless Solution
The solution of keyless proxy.
Stars: ✭ 16 (-36%)
Mutual labels:  nginx
Swizzin
A simple, modular seedbox solution
Stars: ✭ 888 (+3452%)
Mutual labels:  nginx
Nginx Luajit Ws
nginx + nginx-luajit + websocket
Stars: ✭ 19 (-24%)
Mutual labels:  nginx
Dockerfiles
Dockerfiles I create that may or may not be useful.
Stars: ✭ 5 (-80%)
Mutual labels:  nginx
Jale
Jale is a blazing fast local development environment for MacOS written in Typescript.
Stars: ✭ 24 (-4%)
Mutual labels:  nginx
Ansible Role Htpasswd
Ansible Role - htpasswd
Stars: ✭ 17 (-32%)
Mutual labels:  nginx
Docker Php Nginx
Lightwight Docker image for the (latest) PHP-FPM and Nginx based on AlpineLinux
Stars: ✭ 22 (-12%)
Mutual labels:  nginx
Docker Node Nginx Alpine
Dockerfile to build an image with Nginx and Node (npm and yarn) on Alpine Linux
Stars: ✭ 16 (-36%)
Mutual labels:  nginx
Ngx mruby
ngx_mruby - A Fast and Memory-Efficient Web Server Extension Mechanism Using Scripting Language mruby for nginx
Stars: ✭ 891 (+3464%)
Mutual labels:  nginx
Zbx nginx
Zabbix monitoring template for nginx
Stars: ✭ 22 (-12%)
Mutual labels:  nginx
Vestacp nginx pagespeed http2
Rebuild Nginx with Google PageSpeed and http/2 for VestaCP
Stars: ✭ 16 (-36%)
Mutual labels:  nginx
The World Is Yours
Nginx L7 DDoS Protection! And many more features 💥 ⚡️
Stars: ✭ 20 (-20%)
Mutual labels:  nginx
Amazon Scripts
Administrative scripts for my EC2 Amazon Linux based Meteor/Mongo/Nginx/Node/Passenger server
Stars: ✭ 6 (-76%)
Mutual labels:  nginx
Docker Testing
Stars: ✭ 18 (-28%)
Mutual labels:  nginx
Lor
a fast, minimalist web framework for lua based on OpenResty
Stars: ✭ 930 (+3620%)
Mutual labels:  nginx
Ansible Nginx Drupal
Ansible role to configure Nginx for running Drupal using perusio's configuration
Stars: ✭ 23 (-8%)
Mutual labels:  nginx
Nginx Auth Proxy
Authentication for multiple services using nginx
Stars: ✭ 22 (-12%)
Mutual labels:  nginx

MeteorN - A Simple Tool to Run Meteor App with an Nginx Reverse Proxy

MeteorN is meant to help you run your Meteor app with a reverse proxy of Nginx at the front end in docker containers.

A reverse proxy can serve many purpose such as firewall or load balancer.

But for me, the most important thing is that reverse proxy can help me add SSL support to my web app.

This project is composed of two parts.

Use the Basic version if you do not need SSL.

Otherwise, check the SSLImplementd one out.

Notice

  • Ensure docker compose v1.6 or above is installed.
  • Don't play with lsEncrypt too frequently, because there is a quota on how many certificates you can get per week**.

Which Branch to use:

  • master for the newest version of Meteor
  • pre1.4 for older version

How to Use the Basic Version

1. Build Your Meteor App into a Plain Node Js Application

The Meteor tool has a command meteor build that creates a deployment bundle which contains a plain Node.js application.

Before using it, you'll have to install all the npm dependencis for your app in advance.

Also it's important to chose a correct target architecture for your app, you can specify it with --architecture.

Issue these commands inside your Meteor app folder.

npm install --production
meteor build /tmp --architecture os.linux.x86_64

After finishing these two commands, you will find a bundle file in /tmp.(Named as projectName.tar.gz)

2. Clone MeteorN

cd /tmp
git clone https://github.com/lo-tp/MeteorN.git
cp projectName.tar.gz  MeteorN/Basic
cd MeteorN/Basic

3. Build And Run

docker-compose build
docker-compose up

You can also run docker-compose up -d to run your application in the background.

If this is your first time running or you have recreated the containers, then you would have to create the mongo replica set. It's very easy, just run docker exec -it primary mongo /tmp/script/primary.js and you are done.

Now your app is happily running on your server.

How to Use the SSLImplemented Version

It's largely similiar to the use of the Basic version.

All the relevant files are located in the MeteorN/SSLImplemented folder.

There is one more thing to be done before using this version.

You'll have to copy your SSL cirtificate file and SSL cirtificate key to the MeteorN/SSLImplemented/ssl folder respectively as cert.pem and privkey.pem.

Then run docker-compose up and your meteor app is ready to go with SSL support.

One thing to mention: The http traffic is redirected to https by default.

If you want to keep the http working, you can edit the Nginx configure file located at conf folder.

How to Use the lsEncrypt Version

In addtion to the steps described in the Basic Version.

Some more file modifications are necessary.

Find these lines in docker-compose.yml.

environment:
	- DOMAIN=www.test.xyz
	- [email protected]

Change the values of MAIL and DOMAIN to your domain name and email address.

Then open conf/cert.conf.

domains = www.test.xyz
[email protected]
rsa-key-size = 4096
authenticator = webroot
webroot-path = /tmp

Change the first two lines to your domain name and email address.

Also change all the domain names from www.test.xyz to your own contained in conf/nginx.conf.

http{
	upstream app_servers {
		server meteor:8080;
	}
	server {
		listen 80 ;
		server_name www.test.xyz                				#This Line
		location '/.well-known/acme-challenge' {
			...
		}
		location / {
			return    301 https://$server_name$request_uri;
		}
	}
	server { 
		listen 443; 
		ssl on; 
		ssl_certificate /etc/letsencrypt/live/www.test.xyz/cert.pem;            #This Line
		ssl_certificate_key /etc/letsencrypt/live/www.test.xyz/privkey.pem;     #This Line
		...
		location / {
		...
		}
	}
}

events {
	worker_connections 1024;
}

Now run docker-compose up and wait for the Nginx container to automatically get the necessary SSL files from Let's Encrypt and serve your website in https mode.

The Configurations about the Mongo Replica Set.

Two files are pertinent to the configuration of the mongo replica set of your app.

  • ./docker-compose.yml.
  • ./script/primary.js.

./docker-compose.yml is where we define our replica set.

version: '2'
services: 
   node:
       container_name: meteor_test
       build: 
         context: .
         dockerfile: ./dockerfiles/node.dockerfile
       environment:
         - MONGO_URL=mongodb://pri:27017/meteor?replicaSet=test&readPreference=primaryPreferred&w=majority
         - MONGO_OPG_URL=mongodb://pri:27017/local?replicaSet=test
         - ROOT_URL=http://127.0.0.1
         - PORT=8080
       command:  node main.js
       restart: always                      
       networks:
               mongo_net:
                       aliases:
                                   - app
       ports:
           - 8080:8080
   primary:
       container_name: primary_test
       image: mongo:3.2.8
       restart: always                      
       volumes:
           - ./script/:/tmp/script/
       command: [mongod,--replSet,test]
       networks:
               mongo_net:
                       aliases:
                               - pri
networks:
     mongo_net:

Take this snippet as an example,we defined two docker services, one to run the app and one to serve as a primary in the mongo replica set.

In this docker-compose file, a subnet named mongo_net and all the two services above have alias in this subnet. All the aliases are used to compose the MONGO_URL and MONGO_OPG_URL environment variables for the node service.

Then let's check the ./script/primary.js.

var secondaries=['s1'];
var arb='arb';
rs.initiate();
secondaries.forEach(function(address){
  print(address);
  rs.add(address);
});
rs.addArb(arb);
rs.conf();

What this file does is to initiate a replica set and add the secondaries and arbiter to it if existing.

The secondaries and the arb variable are where you should store the corresponding aliases.

Advanced replica set configuration can be achived by modifying this java script file.

Use this project as a starting point if you want to incorporate other remote mongo instances into your replica set.

For more infomation about the configuration of mongo replica set, check this page.

Make sure every is ok and fire up your project with docker-compose up.

Now All you have to do is to open a bash inside your primary mongo instance: docker exec -it primary_test bash,

Run the js script to initialize the mongo replica set inside the the previous opened bash: mongo /tmp/script/primary.js

After all these, you project is ready to go.

Use the Nginx Reverse Proxy to Do Other Thing

You can edit the conf/nginx.conf to implement other functionalities with the reverse proxy.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].