Skip to content

Instantly share code, notes, and snippets.

@1mike12

1mike12/instructions.md

Last active Feb 11, 2019
Embed
What would you like to do?
Step By Step Node Nginx Postgres

Ubuntu shit

add larger swapfile

  1. fallocate -l 1G /swapfile
  2. chmod 600 /swapfile
  3. mkswap /swapfile
  4. swapon /swapfile
  5. echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
  • make swapfile persist through restarts

postgres

creating database

installing user and permissions

setup post-install script

Nginx

listening to right folder

config file located at : /etc/nginx/sites-enabled test nginx config : sudo nginx -t systemctl restart nginx

upstream backend {
server localhost:8080;
}
server {
##performance crap copied form internet
#############################################
# copies data between one FD and other from within the kernel
# faster then read() + write()
sendfile on;
# send headers in one peice, its better then sending them one by one
tcp_nopush on;
# don't buffer data sent, good for small data bursts in real time
tcp_nodelay on;
# reduce the data that needs to be sent over network -- for testing environment
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json a$ # allow the server to close connection on non responding client, this will free up memory
reset_timedout_connection on;
# request timed out -- default 60
client_body_timeout 45;
# if client stop responding, free up memory -- default 60
send_timeout 45;
# server will close connection after this time -- default 75
keepalive_timeout 30;
#hide version number to public
server_tokens off;
## actual config
#####################a##########################
listen 80;
server_name localhost;
root /var/www/project/reactcode/build;
# specify index file
index index.html;
location /api {
proxy_pass http://backend;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Following is necessary for Websocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
#/index.html
try_files $uri $uri/ /index.html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment