Added NGINX and README

This commit is contained in:
Marco van Dijk 2022-03-02 00:55:53 +01:00
parent c2c07aadf7
commit 25cc07814c
2 changed files with 110 additions and 0 deletions

36
README Normal file
View File

@ -0,0 +1,36 @@
Setup VPS
Install pm2, nodejs, nginx, certbot, certbot-nginx, npm
git clone https://github.com/stronk-dev/LivepeerEvents.git /var/www
cd /var/www
npm install
cd /var/www/backend
npm install
nano /var/www/backend/src/config.js to your liking
replace nginx conf with supplied one, certbot will upgrade it to HTTPS
systemctl enable --now nginx.service
certbot --nginx
Connect Backend
cd /var/www/backend
pm2 start ecosystem.config.js --env production
pm2 save
pm2 startup
Monitor Backend
pm2 log backend
pm2 stop backend
pm2 start backend
Run in test environment:
Run backend as 'npm run dev'
Run frontend as 'npm start'
Update frontend production:
cd /var/www
git pull
npm run build
Update backend production
pm2 restart backend
pm2 start ecosystem.config.js --env production

74
nginx/nginx.conf Normal file
View File

@ -0,0 +1,74 @@
#user html;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
sendfile on;
keepalive_timeout 65;
#list of bots who could index website
map $http_user_agent $limit_bots {
default 0;
~*(adbeat_bot|ahrefsbot|alexibot|appengine|aqua_products|archive.org_bot|archive|asterias|attackbot|b2w|backdoorbot|becomebot|blackwidow|blekkobot) 1;
~*(blowfish|botalot|builtbottough|bullseye|bunnyslippers|ccbot|cheesebot|cherrypicker|chinaclaw|chroot|clshttp|collector) 1;
~*(control|copernic|copyrightcheck|copyscape|cosmos|craftbot|crescent|curl|custo|demon) 1;
~*(disco|dittospyder|dotbot|download|downloader|dumbot|ecatch|eirgrabber|email|emailcollector) 1;
~*(emailsiphon|emailwolf|enterprise_search|erocrawler|eventmachine|exabot|express|extractor|extractorpro|eyenetie) 1;
~*(fairad|flaming|flashget|foobot|foto|gaisbot|getright|getty|getweb!|gigabot) 1;
~*(github|go!zilla|go-ahead-got-it|go-http-client|grabnet|grafula|grub|hari|harvest|hatena|antenna|hloader) 1;
~*(hmview|htmlparser|httplib|httrack|humanlinks|ia_archiver|indy|infonavirobot|interget|intraformant) 1;
~*(iron33|jamesbot|jennybot|jetbot|jetcar|joc|jorgee|kenjin|keyword|larbin|leechftp) 1;
~*(lexibot|library|libweb|libwww|linkextractorpro|linkpadbot|linkscan|linkwalker|lnspiderguy|looksmart) 1;
~*(lwp-trivial|mass|mata|midown|miixpc|mister|mj12bot|moget|msiecrawler|naver) 1;
~*(navroad|nearsite|nerdybot|netants|netmechanic|netspider|netzip|nicerspro|ninja|nutch) 1;
~*(octopus|offline|openbot|openfind|openlink|pagegrabber|papa|pavuk|pcbrowser|perl) 1;
~*(perman|picscout|propowerbot|prowebwalker|psbot|pycurl|pyq|pyth|python) 1;
~*(python-urllib|queryn|quester|radiation|realdownload|reget|retriever|rma|rogerbot|scan|screaming|frog|seo) 1;
~*(scooter|searchengineworld|searchpreview|semrush|semrushbot|semrushbot-sa|seokicks-robot|sitesnagger|smartdownload|sootle) 1;
~*(spankbot|spanner|spbot|spider|stanford|stripper|sucker|superbot|superhttp|surfbot|surveybot) 1;
~*(suzuran|szukacz|takeout|teleport|telesoft|thenomad|tocrawl|tool|true_robot|turingos) 1;
~*(twengabot|typhoeus|url_spider_pro|urldispatcher|urllib|urly|vampire|vci|voideye|warning) 1;
~*(webauto|webbandit|webcollector|webcopier|webcopy|webcraw|webenhancer|webfetch|webgo|webleacher) 1;
~*(webmasterworld|webmasterworldforumbot|webpictures|webreaper|websauger|webspider|webster|webstripper|webvac|webviewer) 1;
~*(webwhacker|webzip|webzip|wesee|wget|widow|woobot|www-collector-e|wwwoffle|xenu) 1;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
#main website
server {
server_name localhost nframe.nl www.nframe.nl;
root /var/www/build;
index index.html index.htm;
access_log /var/log/nginx/$host.access.log;
error_log /var/log/nginx/$host.error.log;
#Redirect root of website to static HMTL
location / {
#blocks blank user_agents
if ($http_user_agent = "") { return 301 $scheme://www.google.com/; }
if ($limit_bots = 1) {return 301 $scheme://www.google.com/;}
try_files $uri /index.html;
expires -1;
}
#server to access local Node.js service (backend for main website)
location /api {
proxy_set_header host $http_host;
proxy_set_header x-nginx-proxy true;
proxy_read_timeout 5m;
proxy_connect_timeout 5m;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:42609/api;
}
listen 80;
}
}