Last active
August 29, 2015 14:07
-
-
Save KidkArolis/21b6eeb94adb53c8ebf2 to your computer and use it in GitHub Desktop.
Running node.js apps on Ubuntu
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
# /etc/nginx/sites-enabled/myapp.conf | |
# handle HTTPS and route the domain to specific apps | |
# proxy to the node app via port/socket | |
server { | |
listen 443; | |
server_name myapp.com; | |
ssl on; | |
ssl_certificate /home/ubuntu/...; | |
ssl_certificate_key /home/ubuntu/...; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://127.0.0.1:3000; | |
} | |
client_max_body_size 4G; | |
keepalive_timeout 100; | |
} |
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
# /etc/init/myapp.conf | |
# starts the service on boot, keeps it running, captures logs | |
# restart service with `sudo restart myapp` | |
description "myapp upstart script" | |
start on startup | |
stop on shutdown | |
console log | |
respawn | |
respawn limit 5 60 | |
setuid app | |
setgid app | |
chdir /home/app/myapp/current | |
env NODE_ENV=production | |
script | |
exec node /home/app/myapp/current/app.js >> /home/app/myapp/current/log/myapp.log 2>&1 | |
end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment