Web Server

安裝 cors-anywhere "https"
  • 1# JDP
  • 280202018-3-19 17:10:23

如果需要能跑https cors,則要利用letsencrypt-auto產生SSL key
./letsencrypt-auto certonly -d cors.example.com --manual --preferred-challenges dns
#vi cors_anywhere_https.js
加入以下內容
var host = process.env.HOST || '0.0.0.0';
var port = process.env.PORT || 8080;
var fs = require('fs');
var originBlacklist = parseEnvList(process.env.CORSANYWHERE_BLACKLIST);
var originWhitelist = parseEnvList(process.env.CORSANYWHERE_WHITELIST);
function parseEnvList(env) {
  if (!env) {
    return [];
  }
  return env.split(',');
}
var checkRateLimit = require('./lib/rate-limit')(process.env.CORSANYWHERE_RATELIMIT);
var cors_proxy = require('./lib/cors-anywhere');
cors_proxy.createServer({
    httpsOptions: {
        key: fs.readFileSync('/etc/letsencrypt/live/cors.example.com/privkey.pem'),
        cert: fs.readFileSync('/etc/letsencrypt/live/cors.example.com/fullchain.pem')
    },
}).listen(port, host, function() {
  console.log('Running CORS Anywhere on ' + host + ':' + port);
});

CentOS - Run as Service
#npm install pm2@latest -g
#npm install
#pm2 start cors_anywhere_https.js
#pm2 show cors_anywhere_https
#pm2 startup systemd


Reference:
How to setup for https
https://github.com/Rob--W/cors-anywhere/issues/74
https://serverfault.com/question ... hallenge-validation
https://www.digitalocean.com/com ... duction-on-centos-7
倒序瀏覽 看全部 全部回復
暫無回復,快來搶沙發
回復 收藏 轉播 分享 淘帖