Last active
November 4, 2019 08:08
-
-
Save dr-dimitru/ed7b0cc77ea627a06c9af1f791699eda to your computer and use it in GitHub Desktop.
Deploy Meteor + Phusion Passenger + nginx
This file contains hidden or 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
#!/bin/bash | |
rsync -auhiP -e 'ssh -p {sshPort}' /path/to/app/myApp.tar.gz user@host:/home/meteoruser/ |
This file contains hidden or 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
# inside /etc/nginx/sites-enabled/ | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name example.com; | |
root /var/www/myApp/public; | |
passenger_startup_file main.js; | |
passenger_sticky_sessions on; | |
#passenger_env_var MAIL_URL smtp://....; | |
passenger_env_var MONGO_URL mongodb://localhost:27017; | |
#passenger_env_var MONGO_OPLOG_URL mongodb://...; | |
passenger_env_var ROOT_URL http://example.com; | |
#passenger_env_var METEOR_SETTINGS '{...}'; | |
#passenger_env_var DDP_DEFAULT_CONNECTION_URL http://example.com; | |
include /etc/nginx/passenger.conf; | |
location ~ ^/sockjs/ { | |
keepalive_requests 1024; | |
keepalive_timeout 900s; | |
} | |
} |
This file contains hidden or 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
user www-data; | |
worker_processes {numberOfCPUCores}; | |
worker_rlimit_nofile 65536; | |
pid /run/nginx.pid; | |
events { | |
worker_connections {65536/numberOfCPUCores}; | |
multi_accept on; | |
use epoll; | |
} | |
http { | |
access_log off; | |
server_name_in_redirect off; | |
server_tokens off; | |
ignore_invalid_headers on; | |
autoindex off; | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
types_hash_max_size 2048; | |
keepalive_requests 128; | |
reset_timedout_connection on; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
charset utf-8; | |
override_charset off; | |
charset_types text/css text/plain text/vnd.wap.wml application/javascript application/json application/rss+xml application/xml; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; | |
passenger_ruby /usr/bin/passenger_free_ruby; | |
passenger_show_version_in_header off; | |
passenger_max_request_queue_size 512; | |
include /etc/nginx/sites-enabled/*; | |
} |
This file contains hidden or 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
passenger_enabled on; | |
passenger_app_type node; | |
passenger_friendly_error_pages off; |
This file contains hidden or 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
#!/bin/bash | |
tar -xvf myApp.tar.gz | |
rm myApp.tar.gz | |
mkdir -p ./bundle/public | |
cp ./bundle/programs/web.browser/*.css ./bundle/public/ | |
cp ./bundle/programs/web.browser/*.js ./bundle/public/ | |
cp -R ./bundle/programs/web.browser/app/* ./bundle/public/ | |
chown -R meteoruser:meteoruser ./bundle | |
cd ./bundle/programs/server | |
su -s /bin/bash -c 'npm install --production' meteoruser | |
cd ../../../ | |
rm -Rf /var/www/myApp/public/* /var/www/myApp/programs/web.browser/* | |
rm /var/www/myApp/public/*.js /var/www/myApp/public/*.css | |
rsync -azuhiP ./bundle/ /var/www/myApp | |
chown -R meteoruser:meteoruser /var/www/myApp | |
chmod -R 744 /var/www/myApp | |
chmod 755 /var/www/myApp | |
chmod -R 755 /var/www/myApp/public | |
rm -Rf ./bundle | |
passenger-config restart-app /var/www/myApp | |
passenger-status -v | |
tail -n 100 -f /var/log/nginx/error.log |
hey
I tried this approach, But i found mupx-letsencrypt
and use it now, because it just works.
Thanks a lot for you help!! 👍
@FinnFrotscher
Somewhy I haven't been notified about your comments.
Glad you found a way to use SSL with MUPX
letsencrypt
has expressive docs for nginx
on their project page
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this!
How does this work with ssl? I get my
certs
usingletsencrypt
.