-
-
Save gld1982ltd/e5ee034a5b56b77af091 to your computer and use it in GitHub Desktop.
server setup
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-available/daltonmaag.com | |
# create an upstream for the node server | |
upstream node_app { | |
server 127.0.0.1:3000; | |
} | |
server { | |
listen 0.0.0.0:80; | |
server_name testing.daltonmaag.com testweb; | |
access_log /var/log/nginx/damaweb.log; | |
client_max_body_size 10M; | |
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Nginx-Proxy true; | |
# pass requests to the upstream server | |
proxy_pass http://node_app; | |
proxy_redirect off; | |
} | |
# let nginx handle all static file requests | |
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|pdf|txt|js|flv|swf|html|htm|xml|otf|ttf|eot|woff|svg)$ { | |
root /var/www/html/damaweb/public/; | |
access_log off; | |
expires 24h; | |
} | |
} |
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/mime-types.conf | |
# add these lines to /etc/nginx/mime.types so they can be added to gzip_types | |
application/vnd.ms-fontobject eot; | |
application/x-font-ttf ttf; | |
font/opentype ott; | |
font/x-woff woff; | |
# delete any existing eot entry |
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/nginx.conf | |
# gzip settings - the rest of the file can be left as default | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_comp_level 6; | |
gzip_buffers 16 8k; | |
gzip_http_version 1.1; | |
gzip_types text/plain text/css application/json application/x-javascript text/xml | |
application/xml application/xml+rss text/javascript image/svg+xml | |
application/vnd.ms-fontobject application/x-font-ttf font/opentype font/x-woff; |
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/systemd/system/nodejs.service | |
# systemd service file to run node.js app with forever | |
# https://github.com/nodejitsu/forever | |
# after writing the file run the following commands as root: | |
# systemctl enable nodejs.service | |
# systemctl start nodejs.service | |
# nginx should ideally be running with a systemd service too | |
[Unit] | |
Description=node.js service | |
Requires=network.target | |
After=network.target | |
[Service] | |
Type=forking | |
WorkingDirectory=/var/www/html/damaweb | |
ExecStart=/usr/local/bin/forever start --pidFile /var/run/nodejs.pid server.js | |
ExecStop=/usr/local/bin/forever stop server.js | |
PIDFile=/var/run/nodejs.pid | |
User=root | |
Group=root | |
Environment=NODE_ENV=production | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment