- Clone repository and run installation
git clone https://github.com/popovsergiy/scrapoo
npm install
- Customization nginx configuration See config bellow.
- Create data folder
mkdir -p data/scraped/cheapbasket
// and so on
For development run command
au run --watch
For deployment
au build --env prod
Then copy the file index.html and the folder /scripts to the main deployment folder on your server link.
npm run start-cli-linux
node main.js
Before run script on Linux machine you must install xvfb Run HTTP server with next command
npm run start-linux
npm start
or
node index.js
Problem: npm ERR! Cannot read property '0' of undefined Solution: delete node_modules folder and package-lock.json file.
server {
listen 80;
server_name api.scrapoo.agere.com.ua;
root /web/sites/scrapoo/data/production;
index index.html;
location /data/ {
try_files $uri $uri/ =404;
}
location /api/ {
# Simple requests
if ($request_method ~* "(GET|POST)") {
add_header "Access-Control-Allow-Origin" *;
}
# Preflighted requests
if ($request_method = OPTIONS ) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
return 200;
}
proxy_pass http://localhost:1337/api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
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;
}
}