Last active
December 18, 2015 00:07
-
-
Save justinthrelkeld/59a7283c62520eadefec to your computer and use it in GitHub Desktop.
ubuntu + nginx + meteor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# upstart service file at /etc/init/<app-name>.conf | |
description "Meteor.js (NodeJS) application" | |
author "Daniel Speichert <daniel@speichert.pro>" | |
# When to start the service | |
start on started mongodb and runlevel [2345] | |
# When to stop the service | |
stop on shutdown | |
# Automatically restart process if crashed | |
respawn | |
respawn limit 10 5 | |
# we don't use buil-in log because we use a script below | |
# console log | |
# drop root and switch to <app-name> user | |
setuid <app-name> | |
setgid <app-name> | |
script | |
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript | |
# set to home directory of the user Meteor will be running as | |
export PWD=/home/<app-name> | |
export HOME=/home/<app-name> | |
# leave as 127.0.0.1 for security | |
export BIND_IP=127.0.0.1 | |
# the port nginx is proxying requests to | |
export PORT=3000 | |
# this allows Meteor to figure out correct IP address of visitors | |
export HTTP_FORWARDED_COUNT=1 | |
# MongoDB connection string using <app-name> as database name | |
export MONGO_URL=mongodb://localhost:27017/<app-name> | |
# The domain name as configured previously as server_name in nginx | |
export ROOT_URL=http://<host> | |
# optional JSON config - the contents of file specified by passing "--settings" parameter to meteor command in development mode | |
# export METEOR_SETTINGS='{ "somesetting": "someval", "public": { "othersetting": "anothervalue" } }' | |
# Optional email settings: http://docs.meteor.com/#email | |
# commented out will default to no email being sent | |
# you must register with MailGun to have a username and password there | |
# export MAIL_URL=smtp://postmaster@mymetorapp.net:password123@smtp.mailgun.org | |
# alternatively install "apt-get install default-mta" and uncomment: | |
# export MAIL_URL=smtp://localhost | |
exec node /opt/<app-name>/app/main.js >> /home/<app-name>/<app-name>.log | |
end script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream default { | |
server 127.0.0.1:3000; | |
} | |
server { | |
listen 80; | |
server_name localhost; | |
location / { | |
proxy_pass http://default; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forward-Proto http; | |
proxy_set_header X-Nginx-Proxy true; | |
proxy_redirect off; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /opt/<app-name>/app/programs/server/ | |
rm -rf npm/npm-bcrypt/node_modules/bcrypt | |
npm install bcrypt | |
npm i | |
restart <app-name> | |
service nginx stop | |
service nginx start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment